I am trying to write a loop that will cycle through colors and condense the amount of code in my scss file. Here is a simple example of what I have:
$color1:
This is more of a comment on the previous answers. It's possible to combine both answers, which results in pretty elegant code (in my not-so-humble opinion).
I use Dutch color names, I do so on purpose as to make clear we're not dealing with HTML color names.
$rood : #e3004a;
$blauw : #009ee0;
@each $color in ('rood', $rood), ('blauw', $blauw) {
$name: nth($color, 1);
$value: nth($color, 2);
.#{$name} {
a{
background-color: $value;
}
}
}
CSS
.rood a { background-color: #e3004a; }
.blauw a { background-color: #009ee0; }