用 @mixin 复用样式,用内置函数处理数值与颜色。
本节要点
- 混入可以带参数与默认值
- @extend 谨慎使用避免副作用
- math.div 替代斜杠做除法
代码示例
@mixin flex($justify: center) {
display: flex;
align-items: center;
justify-content: $justify;
}
.row { @include flex(space-between); }提示:混入适合生成样式片段,函数适合返回计算结果。