ASP.net MVC导航栏品牌标题文字颜色

时间:2014-11-11 13:47:33

标签: css asp.net-mvc navbar

令人惊讶的是,这个答案很容易找到答案:

我想更改标题中所有ActionLink的文本颜色。 我试过这段代码:

CSS:

.navbar-brand { color: black }
.navbar-brand:visited { color: black }
.navbar-default-color { color: black }

CSHTML:

    @Html.ActionLink("Home", "Index", "Home", new { area = "" }, new { @class = "navbar-brand" })
</div>
<div class="navbar-collapse collapse">

    <ul class="nav navbar-nav">

        <li>@Html.ActionLink("Senders", "Index", "Senders", new { @class = "navbar-brand" })</li>
        <li>@Html.ActionLink("Responders", "Index", "Responders", new { @class = "navbar-brand" })</li>  

    </ul>

我标题中的所有ActionLink都继承了 navbar-brand 的样式。但只有主页 ActionLinks才能让它的文字颜色发生变化。 (见图) http://i.imgur.com/L0HjMk2.png

请注意,ActionLinks 执行实际上继承了文本大小和字体。除了血腥的文字颜色之外的所有东西!

如何使用CSS更改其他ActionLinks的丑陋灰色?

抱歉愚蠢的问题,但为什么这不起作用?

1 个答案:

答案 0 :(得分:7)

最简单的方法:

.navbar-brand { color: black !important }
.navbar-brand:visited { color: black !important }
.navbar-default-color { color: black !important }
.navbar-inverse { color : #FFFFFF !important }

我相信这会发生因为li元素有自己的风格,而css规则首先从元素选择器获取样式,然后是类选择器。

您可以使用Chrome观看此内容 - &gt; F12 - &gt;检查元素