wut*_*wut 0 css asp.net-mvc navbar
令人惊讶的是,这个答案很难找到答案:
我想更改标题中所有ActionLink的文本颜色.我试过这段代码:
CSS:
.navbar-brand { color: black }
.navbar-brand:visited { color: black }
.navbar-default-color { color: black }
Run Code Online (Sandbox Code Playgroud)
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>
Run Code Online (Sandbox Code Playgroud)
我标题中的所有ActionLink都继承了navbar-brand的样式.但只有Home ActionLinks才会改变它的文字颜色.(见图) http://i.imgur.com/L0HjMk2.png
请注意,ActionLinks 做实际上继承文字大小和字体.除了血腥的文字颜色之外的一切!
如何使用CSS更改其他ActionLinks的丑陋灰色?
抱歉愚蠢的问题,但为什么这不起作用?
最简单的方法:
.navbar-brand { color: black !important }
.navbar-brand:visited { color: black !important }
.navbar-default-color { color: black !important }
.navbar-inverse { color : #FFFFFF !important }
Run Code Online (Sandbox Code Playgroud)
我相信这发生了因为li元素有自己的风格,而css规则首先从元素选择器获得样式,然后是类选择器.
您可以使用Chrome - > F12 - > Inspect元素观看此内容
| 归档时间: |
|
| 查看次数: |
9506 次 |
| 最近记录: |