不要:
虽然可以逐行转换此代码(使用
#1894
和
#1400
),例如:
// defaults:
@font-size: none;
@line-height: none;
// styles:
.test {
.-(@s, @h) {@size: @s; @height: @h}
.-(none, @h) {@size: @s}
.-(@s, none) {@height: @h}
.-(@font-size, @line-height);
font: @font-size/@line-height;
}
// user/custom overrides (comment/uncomment to test):
@font-size: 33px;
@line-height: 5.55;
Demo
.
做:
实际上你
不要
如果你采用声明式的方式,那么根本不需要上述任何条件。正确的Less代码就这么简单:
// defaults:
@font-size: 100%;
@line-height: 1.5;
// styles:
.test {
font: @font-size/@line-height;
}
// user/custom overrides (comment/uncomment to test):
@font-size: 33px;
@line-height: 5.55;
Demo
.
请注意,这些“配置”变量都不必是全局的。您可以使用命名空间变量覆盖两个全局默认值(如
this
)也可以使用命名空间默认值(如
this
),等等。