SASS用于带步长的文本字体权重功能



我想迭代font-weight-100、200、300、400、500、600、700、800和900

这是我正在使用的功能

@for $i from 100 through 900 {
.font-weight-#{$i} {
font-weight: 0 + ($i * 1);
}
}

问题是,它正在从100、101、102一直集成到900。如何使此功能更具性能?如何仅输出100、200、300、400、500、600、700、800和900

最简单的解决方案是从1到9迭代,然后乘以100。

@for $i from 1 through 9 {
.font-weight-#{$i * 100} {
font-weight: ($i * 100);
}
}

最新更新