我正在尝试编写一个循环的mixin,用于迭代地增加背景颜色的饱和度。以下是最新的mixin代码:
@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;
}
}
}
无论我如何更改这个内容,所生成的CSS看起来始终是这样的:
.rubric-design .rubric .create-new-criteria .create-criteria-initial-
settings .create-criteria-setting[setting-id="2"] {
background-color: saturate(#90afc8);
}
也许是我计算$percent的方式有问题,一定是某些显而易见的错误!
$percent: percentage((10 * $i) / 100);
。 - webhound