想要覆盖Bootstrap,但如何避免使用!important?

2023-12-25

我正在使用 Bootstrap 并想要覆盖一些 css:当处于禁用状态时,我将删除表单字段中的背景、边框和不允许的指针。

这就是我的 css 的样子:

.no-extras {
  border: 0 !important;
  box-shadow: none !important;
  background-color: white !important;
  cursor: default !important;
}

但我知道使用 !important 是一件坏事。但我应该如何更改代码以避免使用 !important?我试图用“input.no-extras”和类似的方法使其更具体,但到目前为止还没有任何运气......

请参阅此处的示例代码http://plnkr.co/edit/1AuszJ?p=preview http://plnkr.co/edit/1AuszJ?p=preview


您的添加.no-extras只有在.form-group所以你可以使用:

.form-group .no-extras {
    border: 0;
    box-shadow: none;
    background-color: red;
    cursor: default;
}

Plunker http://plnkr.co/edit/bWg53djUY7sW2brwagoh?p=preview

或者您可以使用任何其他父类。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

想要覆盖Bootstrap,但如何避免使用!important? 的相关文章

随机推荐