Does SASS support adding !important to all properties in a mixin?

后端 未结 3 1483
星月不相逢
星月不相逢 2021-01-07 19:21

I am currently using the compass framework and all it\'s helpful CSS3 mixins. I would like to use the border-radius(5px) mixin and have all properties that come

3条回答
  •  天命终不由人
    2021-01-07 20:05

    Cander's answer works for simple variables, which aren`t followed by any other attribute. You could do it like so, for more complex CSS, like the transition property:

    
        @mixin transition($duration, $content:null) {
            -webkit-transition:all $duration linear $content;
            -moz-transition:all $duration linear $content;
            -o-transition:all $duration linear $content;
            transition:all $duration linear $content;
        }
    
    

    I added the $content variable and set it as null. Now you can call the mixin simple with:

    @include transition(0.3s);

    and if you want to add !important, use

    @include transition(0.3s, !important);

    Thanks!

提交回复
热议问题