[英]Change Text Color CSS3
I am trying to change the text color of this link, I am using a twitter bootstrap template. 我正在尝试更改此链接的文本颜色,我使用的是Twitter Bootstrap模板。 I can change the size, font, padding, and background color of this text but I cannot change the text color it's self.
我可以更改此文本的大小,字体,填充和背景颜色,但不能更改其本身的文本颜色。 I am also using a font I got online.
我也使用在线上获得的字体。
HTML: HTML:
<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<!-- You'll want to use a responsive image option so this logo looks good on devices - I recommend using something like retina.js (do a quick Google search for it and you'll find it) -->
@Html.ActionLink("Fat", "Index", new { controller = "Home" }, new { @class = "navbar-brand" })<br />
@Html.ActionLink("Savage", "Index", new { controller = "Home" }, new { @class = "navbar-brand" })
</div>
CSS: CSS:
.navbar-brand {
font-family: 'TribecaRegular';
color: green;
font-size:xx-large;
padding-right: 150px;
}
the font color is always grey never anything else. 字体颜色始终为灰色,别无其他。
You are not hitting the span tag, you need to do something like this: 您没有点击span标签,您需要执行以下操作:
.navbar-brand span{
color:green;
}
.navbar-brand
is colored by bootstrap. .navbar-brand
由引导程序着色。
The rule used by bootstrap is .navbar-default .navbar-brand {...}
引导程序使用的规则是
.navbar-default .navbar-brand {...}
So you need to create an equal or higher specificity rule 因此,您需要创建一个相等或更高的特异性规则
.navbar-default .navbar-brand {
font-family: 'TribecaRegular';
color: green;
font-size:xx-large;
padding-right: 150px;
}
The above will work if it is placed after the bootstrap rule. 如果将其放在引导规则之后,则以上内容将起作用。
Or you could define it with .navbar-default a.navbar-brand
so that it is used regardless of where you place the rule. 或者,您可以使用
.navbar-default a.navbar-brand
定义它,以便无论在哪里放置规则都可以使用它。
.navbar-brand不存在,但是如果将其更改为正确的范围,但仍然遇到问题,请按照Anders的建议定位span标签。
Could always just assign an ID tag to whatever text is needing to be change. 始终可以将ID标签分配给需要更改的任何文本。
.navbar-header #someID{
color: green;
}
Or if you want to hit all of that element, then do as the other posters have said, target the tag 或者,如果您想点击所有该元素,则按照其他海报所述操作,将标签定位
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.