我如何在 LESS 中定义一个 class 为 class="btn btn-primary" 的元素
How can I define in LESS an element that has a class of class="btn btn-primary"
我尝试了所有不同的组合,但似乎无法正确组合。鉴于以下起点,有人可以告诉我如何在 less 中定义它吗:
.btn {
}
您可以使用 LESS parent selector, &
来引用父选择器。
.btn {
&.btn-primary {
color: red;
}
}
这样做实际上是在选择 .btn
也具有 class .btn-primary
.
的元素
上面的 LESS 将编译为以下内容:
.btn.btn-primary {
color: red;
}
我尝试了所有不同的组合,但似乎无法正确组合。鉴于以下起点,有人可以告诉我如何在 less 中定义它吗:
.btn {
}
您可以使用 LESS parent selector, &
来引用父选择器。
.btn {
&.btn-primary {
color: red;
}
}
这样做实际上是在选择 .btn
也具有 class .btn-primary
.
上面的 LESS 将编译为以下内容:
.btn.btn-primary {
color: red;
}