Can a sass @mixin accept an undefined number of arguments?

前端 未结 4 805
暗喜
暗喜 2020-12-25 11:04

I\'m trying to create a sass mixin for transitions. This is what I have so far.

@mixin transition($var)
  -webkit-transition: $var
  transition: $var
         


        
4条回答
  •  半阙折子戏
    2020-12-25 11:29

    When you call the mixin, call it like this:

    @include transition( (color .5s linear, width .5s linear) );
    

    With the extra parens. This will key sass into the fact that you want this used as a single argument.

    EDIT: See Jeremie Parker's answer above if using Sass 3.2 or later. Real Variable Arguments were added in 3.2: http://chriseppstein.github.io/blog/2012/08/23/sass-3-2-is-released

提交回复
热议问题