$color-collection: ('red', 'orange', 'green', 'blue');@for $i from 0 to length($color-collection) { .color-#{$i} { color: unquote(nth($color-collection, $i+1)); }}使用
nth(),也
unquote()如果你想通过引用的字符串。
不过,我个人不会:
$color-collection: (red, rgba(50,50,80, .5), darken(green, 50%), rgba(blue, .5));@for $i from 0 to length($color-collection) { .color-#{$i} { color: nth($color-collection, $i+1); }}因为这样您可以传递任何颜色对象。



