Skip to content

Instantly share code, notes, and snippets.

@pluma pluma/index.html
Created Oct 30, 2014

Embed
What would you like to do?
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Tree</title>
<style id="jsbin-css">
.tree {
width: 400px;
margin: 15px 0;
}
.trunk, .leaf {
background: #ccc;
box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.25);
padding: 15px;
}
.branches {
padding-left: 50px;
}
.leaf, .branch, .trunk {
position: relative;
}
.trunk, .leaf {
box-sizing: border-box;
height: 50px;
margin-bottom: 5px;
}
.leaf:before, .branch:before {
content: ' ';
position: absolute;
padding-bottom: 5px;
top: -30px;
bottom: 0;
left: -25px;
width: 23px;
height: 100%;
border-left: 2px solid black;
}
.leaf:before {
border-bottom: 2px solid black;
}
.leaf:first-child:before {
padding-bottom: 5px;
height: 50%;
top: -5px;
}
.branch.last:before {
height: 50px;
}
.branch > .trunk:before {
box-sizing: border-box;
content: ' ';
position: absolute;
border-bottom: 2px solid black;
width: 25px;
height: 100%;
left: -25px;
top: -25px;
}
</style>
</head>
<body>
<div class="tree">
<div class="trunk">I'm</div>
<div class="branches">
<div class="leaf">a</div>
<div class="leaf">pumpkin</div>
<div class="leaf">man</div>
<div class="branch">
<div class="trunk">I'm</div>
<div class="branches">
<div class="leaf">a</div>
<div class="leaf">pumpkin</div>
<div class="leaf">man</div>
</div>
</div>
<div class="branch last">
<div class="trunk">I'm</div>
<div class="branches">
<div class="leaf">a</div>
<div class="leaf">pumpkin</div>
<div class="leaf">man</div>
</div>
</div>
</div>
</div>
<script id="jsbin-source-css" type="text/css">.tree {
width: 400px;
margin: 15px 0;
}
.trunk, .leaf {
background: #ccc;
box-shadow: inset 0 0 0 1px rgba(0,0,0,0.25);
padding: 15px;
}
$dent: 50px;
$gap: 5px;
$line: 2px;
$box: 50px;
.branches {
padding-left: $dent;
}
.leaf, .branch, .trunk {
position: relative;
}
.trunk, .leaf {
box-sizing: border-box;
height: $box;
margin-bottom: $gap;
}
.leaf:before, .branch:before {
content: ' ';
position: absolute;
padding-bottom: 5px;
top: -($gap + $box / 2);
bottom: 0;
left: -($dent / 2);
width: ($dent / 2 - $line);
height: 100%;
border-left: $line solid black;
}
.leaf:before {
border-bottom: $line solid black;
}
.leaf:first-child:before {
padding-bottom: $gap;
height: 50%;
top: -($gap);
}
.branch.last:before {
height: $box;
}
.branch>.trunk:before {
box-sizing: border-box;
content: ' ';
position: absolute;
border-bottom: $line solid black;
width: ($dent / 2);
height: 100%;
left: -($dent / 2);
top: -($box / 2);
}</script>
</body>
</html>
.tree {
width: 400px;
margin: 15px 0;
}
.trunk, .leaf {
background: #ccc;
box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.25);
padding: 15px;
}
.branches {
padding-left: 50px;
}
.leaf, .branch, .trunk {
position: relative;
}
.trunk, .leaf {
box-sizing: border-box;
height: 50px;
margin-bottom: 5px;
}
.leaf:before, .branch:before {
content: ' ';
position: absolute;
padding-bottom: 5px;
top: -30px;
bottom: 0;
left: -25px;
width: 23px;
height: 100%;
border-left: 2px solid black;
}
.leaf:before {
border-bottom: 2px solid black;
}
.leaf:first-child:before {
padding-bottom: 5px;
height: 50%;
top: -5px;
}
.branch.last:before {
height: 50px;
}
.branch > .trunk:before {
box-sizing: border-box;
content: ' ';
position: absolute;
border-bottom: 2px solid black;
width: 25px;
height: 100%;
left: -25px;
top: -25px;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.