简体   繁体   English

试图在Twitter Bootstrap中自定义nav-pills

[英]Trying to customize nav-pills in Twitter Bootstrap

I'd like to change the rollover color of the pills and the active pill color. 我想改变药丸的翻转颜色和活性药丸的颜色。 My html looks like this: 我的HTML看起来像这样:

 <div class="theme">
    <div class="banner">
        <h1>Sandstorm</h1>
        <ul class="nav nav-pills red">
            <li class="active"><a href="#">Home</a></li>
            <li><a href="#">About</a></li>
            <li><a href="#">Events</a></li>
            <li><a href="#">Contact</a></li>
        </ul>
    </div>
</div>

And my CSS looks like this: 我的CSS看起来像这样:

.red .active a,
.red .active a:hover {
    background-color:red;
}

But the color won't budge. 但颜色不会让步。 What am I missing? 我错过了什么?

(I'd also like to change the font... but maybe that's too ambitious.) (我也想改变字体...但也许这太雄心勃勃了。)

Change your CSS like so: 像这样改变你的CSS:

CSS CSS

.red .active a,
.red .active a:hover{
    background:red !important;
}
.red a:hover {
     background: red !important;
    color:white;
}

Just make sure you are targeting the exact item you want to change. 只需确保定位您要更改的确切项目即可。 If you want only the active pill to be red, then comment out the following CSS to take the hover color-effect away: 如果你只想让活性药丸变成红色,那么请注释掉下面的CSS以取消悬停颜色效果:

.red a:hover {
     background: red !important;
    color:white;
}

Demo JSFiddle 演示JSFiddle

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

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