简体   繁体   English

无法覆盖bootstrap css

[英]Unable to override bootstrap css

I am trying to override the following found in the bootstrap class of "modal-footer" 我试图覆盖在“模态脚”的bootstrap类中找到的以下内容

margin-top: 15px;

I have the following HTML code that does this: 我有以下HTML代码执行此操作:

<div class="modal-footer my-modal-footer-override"></div>

and the following custom css : 以及以下自定义css:

.my-modal-footer-override {
    margin-top: 0px
}

But this does not work. 但这不起作用。 Any suggestions ? 有什么建议么 ?

You could try a more specific selector. 您可以尝试更具体的选择器。 This could do the trick 这可以解决问题

.modal-footer.my-modal-footer-override {
   margin-top: 0px;
}

Multiple class selectors should work in everything newer than IE6. 多个类选择器应该比IE6更新。 Please note the absence of whitespace between the classes: this means that both classes are applied on the same element . 请注意类之间没有空格:这意味着两个类都应用于同一个元素

If this still does not cut it, you could put .modal before this selector, so: .modal .modal-footer.my-modal-footer-override . 如果这仍然没有削减它,你可以把.modal放在这个选择器之前,所以: .modal .modal-footer.my-modal-footer-override

The important! important! declaration could be used as a dirty hack, but I would advise against it. 声明可以用作肮脏的黑客,但我会建议反对它。

Check your CSS import order. 检查您的CSS导入订单。 Make sure your custom css is loaded after Bootstrap. 确保在Bootstrap之后加载自定义css。 Use firebug or chrome dev tools to see if your styling is being overriden because of something imported laterin the html. 使用firebug或chrome dev工具来查看您的样式是否被覆盖,因为html中稍后导入了某些内容。

Have you tried this? 你试过这个吗?

.my-modal-footer-override {
    margin-top: 0px !important;
}

Using !important before the ";" 在“;”之前使用!important will give this rule more weight than the bootstrap css. 会给这个规则比bootstrap css更重要。

You can add that inside yout HTML using ..css.. in the head, or in a new css document. 您可以使用..css ..在头部或新的css文档中添加HTML内部。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM