sass mixin 是直接在样式css引入、还可以动态传参,全局公共样式是在html引用,
个人觉得sass mixin相对于全局公共样式 页面上会更简洁,功能更强大
比如
全局公共样式:
.color{
color:red;
}
.size{
font-size:16px;
}
.size2{
font-size:18px;
}
.active{
background:#fff;
}
<div class="color size active"></div>
<div class="color size2 active"></div>
sass mixin:
@mixin color{
color:red;
}
@mixin size($num){
font-size:$num;
}
.active{
background:#fff;
@include color;
@include size(16px);
}
.active2{
background:#fff;
@include color;
@include size(18px);
}
<div class="active"></div>
<div class="active2"></div>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…