twitter-bootstrap 使用 CSS 更改 Twitter Bootstrap 中按钮的背景颜色

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18682549/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 18:17:50  来源:igfitidea点击:

Change background color of button in Twitter Bootstrap using CSS

htmlcsswordpresstwitter-bootstrap

提问by AlexR

I am using the following paginationbutton styles provided by Twitter Bootstrap:

我正在使用Twitter Bootstrap 提供的以下分页按钮样式:

<ul class="pager">
  <li class="previous"><a href="#">&larr; Older</a></li>
  <li class="next"><a href="#">Newer &rarr;</a></li>
</ul>

This is how they currently look like:

这是它们目前的样子:

enter image description here

enter image description here

How do I need to change my CSS style to change the background color of these buttons from green to some other color?

我需要如何更改我的 CSS 样式以将这些按钮的背景颜色从绿色更改为其他颜色?

I tried this CSS code, but it did not change the button styles:

我试过这个 CSS 代码,但它没有改变按钮样式:

.next {
    background-color: #ecf0f1;
    color: #2d525d;
}

Thank you!

谢谢!

回答by Kousha

You need to overwrite the css codes:

您需要覆盖 css 代码:

.next a {
    background-color: #ecf0f1 !important;
    color: #2d525d !important;
}

Edit:The colorand background-colorstyles are for "a" element inside the li.

编辑:颜色背景颜色样式对于李里面的“a”元素。

回答by web designer philippines

you can also add !important to your custom css

您还可以将 !important 添加到您的自定义 css 中

.next {
background-color: #ecf0f1 !important;
color: #2d525d;
}

回答by Sabba Keynejad

Use

利用

!important

after you css but before ;

在你 css 之后但之前;

It pretty much means ignore anything else and use THIS !important

这几乎意味着忽略其他任何东西并使用这个!重要

you will need to use this to break out of default styling in some frameworks, its also useful for media queries.

您将需要使用它来打破某些框架中的默认样式,这对于媒体查询也很有用。