较少 - 监护人混合良好做法

时间:2015-07-10 09:04:36

标签: css less conditional less-mixins

我为轻度值条件创建了小Less @mixin。我正在使用Sass作为我的应用程序UI,我真的很困惑如何在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;
}

0 个答案:

没有答案