Multiple values for one property with variable argument lists in Sass

后端 未结 1 705
不知归路
不知归路 2020-11-30 13:00

I\'m looking to have a mixin like +stacktextshadow(blue, red, green) spit out text-shadow: 1px 1px 0 blue, 2px 2px 0 red, 3px 3px 0 green;

相关标签:
1条回答
  • 2020-11-30 13:46

    You can create a variable outside the loop to "collect" the shadow values, and then use that variable in your text-shadow property. Example:

    =stacktextshadow($shadows...)
      $all: ()
      @for $i from 1 through length($shadows)
        $all: append($all, append($i*1px $i*1px 0, nth($shadows, $i)), comma)
    
      text-shadow: $all
    
    h1
      +stacktextshadow(blue, red, green)
    

    Output:

    h1 {
      text-shadow: 1px 1px 0 blue, 2px 2px 0 red, 3px 3px 0 green; }
    
    0 讨论(0)
提交回复
热议问题