我的项目中有以下 SASS mixin
@mixin text_3d($color){
color: $color;
text-shadow: 0 3px 0 darken($color, 14%),
0 4px 0 darken($color, 15%),
0 5px 0 darken($color, 16%),
0 6px 0 darken($color, 17%),
3px 8px 15px rgba(0,0,0,0.1),
3px 8px 5px rgba(0,0,0,0.3);
}
我想将多个“文本阴影”行替换为一个循环,但我不知道该怎么做。在伪代码中:
@mixin text_3d($color, $depth){
color: $color;
text-shadow:
@for $i from 0 through $depth {
0 ($i+3)px 0 darken($color, $i+14%),
}
3px 8px 15px rgba(0,0,0,0.1),
3px 8px 5px rgba(0,0,0,0.3);
}
但我不断收到错误,好像我无法将@for 放在那里。
(Line 143: Invalid CSS after " text-shadow:": expected expression (e.g. 1px, bold), was "@for $i from 0 ...")