Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我经常同时设置宽度和高度,所以我这样写。
@mixin size($width,$height){width:$width + px; height:$height + px;}
有更好的方法吗?
我以为有这样的默认mixin,但我找不到。
取出+ px. 这样做会给你的 mixin 更多的灵活性:
+ px
@mixin size($width, $height) { width: $width; height: $height; }
然后,在使用 mixin 时,您可以指定各种单位,例如像素、em、百分比等:
#element { @include size(50%, 100px); }
演示