gpt4 book ai didi

SASS - 通过项目索引获取 map 项目值

转载 作者:行者123 更新时间:2023-12-04 18:59:44 25 4
gpt4 key购买 nike

我希望能够通过该 map 项的索引选择 SASS map 项值。
简化场景:

社会保障局

// 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]; }
}

那可能吗?

最佳答案

gist demo

$colors: (
a: red,
b: green,
c: blue
);

@each $color, $name in $colors{
$i: index($colors, $color $name);
a:nth-child(#{$i}){ color:$color; }
}

关于SASS - 通过项目索引获取 map 项目值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40468351/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com