I'm trying to write looped mixin that iteratively increases the saturation of a background-color. Here's the latest mixin code:
@mixin generateBackgroundSteps($cell-count, $color) {
@for $i from 0 through $cell-count - 1 {
$percent: (5 * $i) + "%";
$new-color: saturate($color, $percent);
&[setting-id="#{$i}"] {
background-color: $new-color;
}
}
}
No matter how I've altered this, the produced css just keeps looking like this:
.rubric-design .rubric .create-new-criteria .create-criteria-initial-
settings .create-criteria-setting[setting-id="2"] {
background-color: saturate(#90afc8);
}
Maybe it's the way I'm forming $percent. It must be something obvious!
Try using percentage function.
percentage function in SCSS
$percent: percentage((5 * $i) / (5 * $cell-count));
@mixin generateBackgroundSteps($cell-count, $color) {
@for $i from 0 through $cell-count - 1 {
$percent: percentage((5 * $i) / (5 *$cell-count));
$new-color: saturate($color, $percent);
&[setting-id="#{$i}"] {
background-color: $new-color;
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With