0

我为亮度值条件创建了小的 Less @mixin。我在我的应用程序 UI 中使用 Sass,我真的很困惑如何在 Less 中创建好的条件。任何人都可以回答我,这是少条件的好代码吗?

少源:

.lightness (@conditionalValue, @lightnessPercentage, @propertyName, @truePropertyValue, @falsePropertyValue) when (lightness(@conditionalValue) >= @lightnessPercentage) {
    @{propertyName}: @truePropertyValue;
}
.lightness (@conditionalValue, @lightnessPercentage, @propertyName, @truePropertyValue, @falsePropertyValue) when (lightness(@conditionalValue) < @lightnessPercentage) {
    @{propertyName}: @falsePropertyValue;
}


.class1 { .lightness(white,65%,background,black,white) }
.class2 { .lightness(black,65%,background,black,white) }

CSS输出:

.class1 {
  background: black;
}
.class2 {
  background: white;
}
4

0 回答 0