pass a list to a mixin as a single argument with SASS

后端 未结 6 1090
悲哀的现实
悲哀的现实 2021-01-30 06:35

I like to make mixins with SASS that help me make good cross-browser compatibility. I want to make a mixin that looks like this:

@mixin box-shadow($value) {
             


        
6条回答
  •  春和景丽
    2021-01-30 07:22

    i want to point out that you can also pass a value using the argument name as you call the mixin:

    @mixin shadow($shadow: 0 0 2px #000) {
        box-shadow: $shadow;
        -webkit-box-shadow: $shadow; 
        -moz-box-shadow: $shadow; 
    }
    
    .my-shadow {
      @include shadow($shadow: 0 0 5px #900, 0 2px 2px #000);
    }
    

    note that scss is scoped so $shadow will still retain its mixin value if used again later. less i believe, suffers from reassignment in this scenario

提交回复
热议问题