Accessing an array key in SASS

前端 未结 4 1785
鱼传尺愫
鱼传尺愫 2020-12-05 00:43

I have a list in SASS, and I\'m trying to access on of the items by using bracket notation:

$collection[1];

but that gives me an error.

4条回答
  •  青春惊慌失措
    2020-12-05 01:04

    I had similar problem and tried Alex Guerrero solution. Didn't work form me cause output was like .color-gray:{gray}; instead of .color-1:{gray};.So I modified it a bit and it looks like this:

    $color-pallete: (gray, white, red, purple)
    
    $i: 0
    @each $color in $color-pallete
        .color-#{$i}
            color: $color
        $i: $i + 1
    

    Oh, ye. I use SASS, not SCSS.

提交回复
热议问题