Skip to content

Instantly share code, notes, and snippets.

@websanya
Created April 11, 2014 08:38
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 websanya/10450406 to your computer and use it in GitHub Desktop.
Save websanya/10450406 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
// ----
// 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);
}
}
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