假设你有一个像这样的阴影混合:
@mixin box-shadow($offset, $blur, $color)
{
-moz-box-shadow: $offset $offset $blur $color;
-webkit-box-shadow: $offset $offset $blur $color;
box-shadow: $offset $offset $blur $color;
}
是否可以使用以下内容重载该 mixin:
@mixin box-shadow($offset, $blur)
{
@include box-shadow($offset, $blur, #999);
}
或者我必须为 mixin 使用不同的名称吗?
您不能超载,但典型的做法是设置默认值。
/* 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;
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)