Skip to content

Instantly share code, notes, and snippets.

@splosch
Created February 10, 2015 20:14
Show Gist options
  • Save splosch/f8dacc801ee50e2b45a0 to your computer and use it in GitHub Desktop.
Save splosch/f8dacc801ee50e2b45a0 to your computer and use it in GitHub Desktop.
SASS / SCSS: colorloop
<h1 class="title">SCSS :: COLORLOOP</h1>
<ul class="boxes">
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
</ul>

SASS / SCSS: colorloop

given a list of hex-colors this SASS code allows to color siblings while iterating through this color list

A Pen by Mario Winkler on CodePen.

License.

$boxcolors: #FFC78B , #E6AB6B , #E6C46B , #608FA1, #6E74AE, #C3C8F8 , #BCE7F7;
@each $boxcolor in $boxcolors {
$boxindex: index($boxcolors, $boxcolor);
.boxes > li:nth-child(#{$boxindex}) {
background-color: #{$boxcolor};
}
}
html, body, {
width: 100%;
height: 100%;
display: table;
}
.boxes {
display: table-row;
width: 100%;
> li {
height: 100%;
width: 14%;
display: table-cell;
}
}
.title {
position: absolute;
width: 100%;
height: 100%;
padding-top: 0.51em;
display: block;
box-sizing: border-box;
text-align: center;
color: #FFF;
font-family: 'Gotham SSm A', 'Gotham SSm B', "Lucida Grande","Lucida Sans Unicode", Tahoma, sans-serif;
font-size: 5em;
font-weight: bold;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment