简体   繁体   English

如何在LESS中定义具有class =“ btn btn-primary”类的元素

[英]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.

相关问题 如何将btn btn-primary类添加到锚标记? - How to add btn btn-primary class to anchor tag? 如何在 React bootstrap Styled Component 中覆盖 -btn-primary 类 - How to override -btn-primary class in React bootstrap Styled Component 如何从我的 custom.css 文件中应用 btn btn-primary bootstrap class? - how to apply btn btn-primary bootstrap class from my custom.css file? 更改 Bootstrap btn-primary class 的默认颜色 - Change default color of Bootstrap btn-primary class Bootstrap btn-primary按钮意外的悬停颜色和效果。 我该如何改写? - Bootstrap btn-primary button unintended hover color and effect. How do I override this? Bootstrap btn-primary出现在悬停上 - Bootstrap btn-primary appear on hover Twitter Bootstrap“ Dropdown Toggle”是否位于“ btn btn-block btn-lg btn-primary”上? - Twitter Bootstrap “Dropdown Toggle” on “btn btn-block btn-lg btn-primary”? 如何在按钮中为大纲编写 CSS,因为 class="btn btn-outline-primary" 不起作用? - How to write CSS for outline in button as class="btn btn-outline-primary" not working? 如何使用SASS覆盖Bootstraps“ btn-primary”活动背景色? - How to override Bootstraps “btn-primary” active background-color using SASS? Twitter Bootstrap btn-primary大小IE8 - Twitter Bootstrap btn-primary Size IE8
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM