Accessing the name of the variable rather than its value

前端 未结 4 1183
遥遥无期
遥遥无期 2021-01-14 12:56

I am trying to write a loop that will cycle through colors and condense the amount of code in my scss file. Here is a simple example of what I have:

$color1:         


        
4条回答
  •  不知归路
    2021-01-14 13:40

    According to the sass-reference your code should look like this, but i haven´t tried it myself.

    @each $color in $color1, $color2, $color3, $color4 {
      .#{$color}-bg { background-color: $color;}
      .#{$color}-border { border-color: $color;}
    }
    

    http://sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html#control_directives

提交回复
热议问题