I try to darken a variable number of divs like that with following code:
@mixin color-divs ($count, $baseName, $startcolor) {
$color: $startcolor;
@for $i from 0 through $count {
$color: darken($color, 9%);
##{$baseName}_#{$i} { background-color:$color; }
}
}
With that code I was expecting, that the variable $color is changed with every iteration but this didn't work as expected. The value is fix after the fist initialisation and every element has the same color.
Is there a way to workarround that problem or is there another way to solve that problem with a mixing?
You can darken the color using $i inside @for and apply respective classes to the divs. Hope this helps.
SCSS
HTML
Demo
See demo
I created this example based on your mixin:
Used with the following markup:
Output: http://jsfiddle.net/jdtvF/
http://uk.omg.li/P0dF/by%20default%202013-05-16%20at%2010.10.43.png