更改bootstrap中活动的类的颜色

问题描述 投票:6回答:3

我正在尝试更改我的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>

如何改变它的颜色?谢谢你..

html css twitter-bootstrap background-color
3个回答
9
投票

您可以使用:

.active a{
    color: red !important;
}

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

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

DEMO


4
投票

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

a {
   color: red !important;
  }

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

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

0
投票

如果以上答案不起作用试试 -

.active a{
    background-color : red !important;
}
© www.soinside.com 2019 - 2024. All rights reserved.