Multiple properties are getting treated as separate arguments in mixins

后端 未结 4 1616
北海茫月
北海茫月 2020-12-03 05:31

I\'m trying to write a mixin, but I can\'t seem to get the arguments working the way I want: multiple properties are getting treated each as a separate argument.

Cu

4条回答
  •  春和景丽
    2020-12-03 05:59

    Using the solution found here works with one AND multiple arguments:

    .transition (@value1,@value2:X,...)
    {
        @value: ~`"@{arguments}".replace(/[\[\]]|\,\sX/g, '')`;
    
        -webkit-transition: @value;
        -moz-transition: @value;
        -ms-transition: @value;
        -o-transition: @value;
        transition: @value;
    }
    

    Using it this way:

    .transition(color, opacity .5s ease-in-out);
    

    yields:

    -webkit-transition: color, opacity .5s ease-in-out;
    -moz-transition: color, opacity .5s ease-in-out;
    -ms-transition: color, opacity .5s ease-in-out;
    -o-transition: color, opacity .5s ease-in-outt;
    transition: color, opacity .5s ease-in-out;
    

提交回复
热议问题