[英]How can I define in LESS an element that has a class of class=“btn btn-primary”
I have tried all different combinations but don't seem to be able to get it right. 我尝试了所有不同的组合,但似乎无法正确处理。 Can someone help by telling me how I can define this in less given the starting point of:
有人可以告诉我如何从以下出发点来简化定义:
.btn {
}
You could use the LESS parent selector, &
, to reference the parent selector. 您可以使用LESS父选择器
&
来引用父选择器。
.btn {
&.btn-primary {
color: red;
}
}
In doing so, you are essentially selecting .btn
elements that also have the class .btn-primary
. 这样做实际上是在选择
.btn
元素,它们也具有.btn-primary
类。
The above LESS will compile to the following: 上面的LESS将编译为以下内容:
.btn.btn-primary {
color: red;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.