Skip to content

Instantly share code, notes, and snippets.

@renancouto
Created February 21, 2013 16:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save renancouto/5006197 to your computer and use it in GitHub Desktop.
Save renancouto/5006197 to your computer and use it in GitHub Desktop.
A CodePen by renancouto. 50 Shades of Gray - Just a quick experiment with SCSS's while loop.
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
<h1>50 Shades of Gray</h1>
var i = 0, m = '', c;
for (i; i < 50; i++) {
c = i + 1;
m += '<span class="shade-' + c + '">' + c + '</span>';
}
$('body').append(m);
@import "compass";
body {
font: 14px Arial;
padding: 20px;
}
h1 {
font-size: 20px;
font-weight: 700;
margin-bottom: 10px;
text-align: center;
}
span {
border: 1px solid #fff;
float: left;
padding: 15px 0;
width: 65px;
text-align: center;
text-shadow: rgba(255,255,255,.2) 0 1px 0;
&:after {
display: block;
font-size: 11px;
}
}
$i: 50;
@while $i > 0 {
.shade-#{$i} {
$c: darken(#fff, $i);
background: $c;
&:after { content: '#{$c}'; }
}
$i: $i - 1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment