Html 更改引导程序中活动类的颜色

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/31396803/
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-08-29 11:46:12  来源:igfitidea点击:

change the color of class active in bootstrap

htmlcsstwitter-bootstrapbackground-color

提问by sang

i'm trying to change the color of class active in my html code. i'm creating nav sidebar. here's my code:

我正在尝试更改我的 html 代码中活动类的颜色。我正在创建导航侧边栏。这是我的代码:

<div class="col-sm-2">
                <ul class="nav nav-pills nav-stacked nav-static"> <!--stacked untuk jadi vertical -->
                    <li class="active"><a>Create Case</a></li>
                    <li><a href="wf-listofcase.php">List of cases</a></li>
                    <li><a href="linksofapps.html">Links of Apps</a></li>
                </ul>
    </div>

how to change its color? thanks before..

如何改变它的颜色?之前谢谢..

回答by lmgonzalves

You can use:

您可以使用:

.active a{
    color: red !important;
}

Or to avoid !important, use:

或者为了避免!important,使用:

.nav-pills > li.active > a{
    color: red;
}

DEMO

演示

回答by prajeesh

The following code applies red color for all the anchor tags.

以下代码为所有锚标记应用红色。

a {
   color: red !important;
  }

To apply the color only within the "nav-static" wrapper, use the following code.

要仅在“nav-static”包装器内应用颜色,请使用以下代码。

.nav-static .active a{
   color: red !important;
}

回答by Burhan Shakir

If the above answers don't work try out -

如果上述答案不起作用,请尝试-

.active a{
    background-color : red !important;
}