Created
April 11, 2014 08:38
-
-
Save websanya/10450406 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
This file contains hidden or 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
// ---- | |
// Sass (v3.3.4) | |
// Compass (v1.0.0.alpha.18) | |
// ---- | |
// List of colors | |
$colors_list: red, blue, green; | |
// Map of colors | |
$colors_map: ( | |
"red": #f01, | |
"blue": #10f, | |
"green": #1f0 | |
); | |
// Number of elements | |
$n: 2; | |
// @for loop for lists of colors | |
@for $i from 0 to $n { | |
div:nth-of-type(#{$i+1}) { | |
/* first loop */ | |
background: nth($colors_list, $i % length($colors_list) + 1); | |
} | |
} | |
// @for loop for maps of colors | |
@for $i from 0 to $n { | |
div:nth-of-type(#{$i+1}) { | |
/* second loop */ | |
background: nth(nth($colors_map, $i % length($colors_map) + 1), 2); | |
} | |
} |
This file contains hidden or 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
div:nth-of-type(1) { | |
/* first loop */ | |
background: red; | |
} | |
div:nth-of-type(2) { | |
/* first loop */ | |
background: blue; | |
} | |
div:nth-of-type(1) { | |
/* second loop */ | |
background: #ff0011; | |
} | |
div:nth-of-type(2) { | |
/* second loop */ | |
background: #1100ff; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment