Created
April 12, 2015 16:35
-
-
Save KarafiziArtur/a4ad636efe0e6d6397ca to your computer and use it in GitHub Desktop.
Цвета подставить через цикл
From http://sassmeister.com/gist/10450406
This file contains 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); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment