我希望能够通过该地图项目的索引选择SASS地图项目值 简化方案:
// Colors map (MUST stay this way due to system dependence)
$colors: (
a: red,
b: green,
c: blue
);
@for $i from 1 through 3{
a:nth-child({$i}){ color:[GET COLOR BY $i FROM $COLORS]; }
}
这可能吗?
答案 0 :(得分:4)
$colors: (
a: red,
b: green,
c: blue
);
@each $color, $name in $colors{
$i: index($colors, $color $name);
a:nth-child(#{$i}){ color:$color; }
}