Is it possible to overload mixins in sass?

前端 未结 3 878
感动是毒
感动是毒 2021-02-04 00:59

Let say you have a mixin for shadow like such:

@mixin box-shadow($offset, $blur, $color)
{
   -moz-box-shadow: $offset $offset $blur $color;
   -webkit-box-shado         


        
3条回答
  •  南方客
    南方客 (楼主)
    2021-02-04 01:05

    You can't overload, but the typical practice would be to set defaults.

     /* this would take color as an arg, or fall back to #999 on a 2 arg call */
     @mixin box-shadow($offset, $blur, $color: #999) {
       -webkit-box-shadow: $offset $offset $blur $color;
       -moz-box-shadow: $offset $offset $blur $color;
       box-shadow: $offset $offset $blur $color;
     }
    

提交回复
热议问题