这段使用mixin函数的SASS代码是否过于冗长



我觉得这个mixin的代码太冗长了,请帮忙
请随时传递有关混合的任何建议。

@mixin bold { font-weight: bold; }
@mixin normal { font-weight: normal; }
@mixin font($bold, $normal) {
@if ($bold) {
@include bold
} @else {
font-weight: normal;
}
}
h1 { @include font(false, false) }
h2 { @include font(true, true) }

您可以简化它:

$bold: 700;
$normal: 400;
h1 {
font-weight: $bold;
}
h2 {
font-weight: $normal;
}

最新更新