Skip to content

Instantly share code, notes, and snippets.

@rpearce
Created April 27, 2012 06:23
Show Gist options
  • Save rpearce/2506434 to your computer and use it in GitHub Desktop.
Save rpearce/2506434 to your computer and use it in GitHub Desktop.
SASS for and while example1
(ripped from sass-lang.com docs)
@for $i from 1 through 3 {
.item-#{$i} { width: 2em * $i; }
}
(compiles to...)
.item-1 {
width: 2em; }
.item-2 {
width: 4em; }
.item-3 {
width: 6em; }
//////////////////////////////////////////////////////////////
$i: 6;
@while $i > 0 {
.item-#{$i} { width: 2em * $i; }
$i: $i - 2;
}
(compiles to...)
.item-6 {
width: 12em; }
.item-4 {
width: 8em; }
.item-2 {
width: 4em; }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment