Using Sass, style a list with each line full width, but content is inset appropriately, and recursively.
Created
June 20, 2016 22:37
-
-
Save thetypebeast/0a484db23266b04fe064067911728457 to your computer and use it in GitHub Desktop.
Recursive List - Full Width
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<ul> | |
<li class="level-0"> | |
<div>Level 1</div> | |
<ul> | |
<li class="level-1"> | |
<div>Level 2</div> | |
<ul> | |
<li class="level-2"> | |
<div>Level 3</div> | |
<ul> | |
<li class="level-3"> | |
<div>Level 4</div> | |
<ul> | |
<li class="level-4"> | |
<div>Level 5</div> | |
<ul> | |
<li class="level-5"> | |
<div>Level 6</div> | |
</li> | |
</ul> | |
</li> | |
</ul> | |
</li> | |
</ul> | |
</li> | |
<li class="level-2"> | |
<div>Level 2 B</div> | |
</li> | |
</ul> | |
</li> | |
</ul> | |
</li> | |
<li class="level-0"> | |
<div>Level 1 B</div> | |
</li> | |
</ul> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@import url(https://fonts.googleapis.com/css?family=Raleway); | |
body { | |
margin: 0; | |
background-color: #ababab; | |
font-family: 'Raleway', sans-serif; | |
color: #fff; | |
} | |
$i:0; | |
@for $i from 0 through 6 { | |
.level-#{$i} { | |
& div { | |
margin-left: 40px * $i !important; | |
} | |
} | |
} | |
ul { | |
margin: 0; | |
padding: 0; | |
li { | |
list-style-type: none; | |
padding: 0; | |
margin: 0; | |
border: 1px solid #fff; | |
border-width: 1px 0px 0px; | |
background-color: transparentize(#000, .75); | |
} | |
& > ul > li { | |
background-color: transparent; | |
} | |
& div { | |
padding: 20px; | |
&:last-child { | |
border-bottom-width: 5px; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment