第n项上的Sass循环
我有4个列表项,每个都需要不同的背景色 我可以将我的4个不同颜色变量放在Sass列表中,每个变量都作为第n项上的Sass循环,sass,each,Sass,Each,我有4个列表项,每个都需要不同的背景色 我可以将我的4个不同颜色变量放在Sass列表中,每个变量都作为$color通过,但在循环的内容块中,我显然需要指定我所说的使用类型的:n1、2、3或4 我不知道如何指定在循环的每一圈中需要哪个 有什么想法吗?这应该可以做到: $colors: (#000, #F00, #0F0, #00F); @for $i from 1 through length($colors) { li:nth-of-type(#{$i}) { backgro
$color
通过,但在循环的内容块中,我显然需要指定我所说的使用类型的:n1、2、3或4
我不知道如何指定在循环的每一圈中需要哪个
有什么想法吗?这应该可以做到:
$colors: (#000, #F00, #0F0, #00F);
@for $i from 1 through length($colors) {
li:nth-of-type(#{$i}) {
background: nth($colors, $i);
}
}
它产生:
li:nth-of-type(1) {
background: black; }
li:nth-of-type(2) {
background: red; }
li:nth-of-type(3) {
background: lime; }
li:nth-of-type(4) {
background: blue; }