我有一个定义为:Less的混入:
.fontStyle(@family, @size, @weight: normal, @style: normal, @color: #ffffff, @letter-spacing: normal) {
font-family: @family;
font-size: @size;
color: @color;
font-weight: @weight;
font-style: @style;
letter-spacing: @letter-spacing;
}我如何定义用法,如:
.fontStyle('NimbusSansNovCon-Reg', 12px, , , , 0.1em);例如,使用@weight、@style、@color的默认值
发布于 2013-06-15 04:28:10
要提供一个位于参数字符串下方的参数,您还必须提供它要定义的预期变量。所以这就是:
.fontStyle('NimbusSansNovCon-Reg', 12px, @letter-spacing: 0.1em);生成以下代码(请注意color、font-weight和font-style如何使用默认值):
font-family: 'NimbusSansNovCon-Reg';
font-size: 12px;
color: #ffffff;
font-weight: normal;
font-style: normal;
letter-spacing: 0.1em;发布于 2014-04-13 04:07:07
请参阅文档
http://lesscss.org/features/#mixins-parametric-feature-mixins-with-multiple-parameters
注意:您应该养成使用分号分隔参数的习惯,因为一些css值可以包含逗号。
https://stackoverflow.com/questions/17116082
复制相似问题