在 Sass 中,使用“@mixin”来声明一个混合宏:
@mixin border-radius{
-webkit-border-radius: 5px;
border-radius: 5px;
}
带参数的混合宏:
@mixin border-radius($radius:5px){
-webkit-border-radius: $radius;
border-radius: $radius;
}
到表达式的混合宏:
@mixin box-shadow($shadow,$color) {
@if length($shadow) >= 1 { $color: red;
} @else{ $color: green; }}
混合宏调用混合宏 "@include"调用宏
@mixin border-radius{
-webkit-border-radius: 3px;
border-radius: 3px;
}
button {
@include border-radius;
}