[英]Overwriting an anchor tag styling in css bootstrap
I am want my active link to be red:我希望我的活动链接是红色的:
nav class="navbar navbar-inverse">
<div class="container col-1 col-sm-12">
<ul class="nav">
<li class="<%= 'active' if current_page?(squad_path) %>"><%= link_to("squad", squad_path)%></li>
<li class=" <%= 'active' if current_page?(album_path) %>"><%= link_to("album", album_path)%></li>
...
When I inspect the page, the li tag is active but doesn't change the color on the site.当我检查页面时, li标记处于活动状态,但不会更改站点上的颜色。 The hover is working fine changing by color.
悬停工作正常,按颜色更改。
This is my CSS code:这是我的 CSS 代码:
.nav li a{
display: inline-block;
padding-right: 8px;
padding-left: 8px;
color: #fff;
margin-bottom: 3px;
margin-top: 3px;
font-size: 40px;
font-family: "Germanica";
}
.nav li a:hover{
text-decoration: none;
color: #ff0000;
background-color: black;
}
.nav li .active a {
color: #ff0000 !important;
}
Still, when I want to change the background color - it works.尽管如此,当我想更改背景颜色时 - 它有效。 Just doesn't change color of the text.
只是不改变文本的颜色。
You can do:你可以做:
.nav li.active a {
color: #ff0000;
}
This way you can also get rid of the !important
because it is more specific than the other rules这样你也可以摆脱
!important
因为它比其他规则更具体
Ok, I just worked it out one moment later.好的,我只是在一分钟后解决了它。 I deleted "li" from the css line and it worked.
我从 css 行中删除了“li”并且它起作用了。 Probably because .active is the class name of that li tag.
可能是因为.active是那个li标签的类名。
.nav .active a {
color: #ff0000 !important;
}
Hope it will help somebody else.希望它会帮助别人。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.