[英]How can I pass a value to a variable in LESS?
I'd like to pass a value to a variable in LESS. 我想将值传递给LESS中的变量。 How can I do this?
我怎样才能做到这一点?
Here's some sample code. 这是一些示例代码。 I'd like to pass the values in
.className()
to the variable @varValue
. 我想将
.className()
的值传递给变量@varValue
。
@defaultWidth: 10px;
.className(@varValue: 1) {
width: (@defaultWidth * @varValue);
background: green;
}
.sample {
background: blue;
height: 10px;
.filled_1 { .className(1); }
.filled_2 { .className(2); }
.filled_3 { .className(3); }
}
Example HTML: HTML示例:
<div class="sample">
<div class="filled_3"></div>
</div>
As Guy Morgrabi stated in the comment above, it's an issue with different LESS compiler versions. 正如盖伊Morgrabi在上面的评论说,这是不同的LESS编译器版本的问题。 Guy should get the credit, but for the others visiting, you should know the answer.
盖伊应该得到荣誉,但是对于其他来访的人,您应该知道答案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.