我的主导航栏是这样的:JSFIDDLE
<div id="navbar">
<ul>
<li><a href="index.html">Home</a></li>
<li><a href="bio.html">Bio</a></li>
<li><a href="projects.html">Projects</a></li>
<li id="active"><a href="contact.html">Contact</a></li>
<li><a href="friends.html">Friends</a></li>
</ul>
</div>
它的css如下:
#navbar {
float: left;
height: 100px;
width: 395px;
background-color: orange;
background-color: #CCCCCC;
background-image: url(../images/1_03.jpg);
}
#navbar ul{
list-style-type: none;
margin-top: 30px;
}
#navbar li{
float: left;
text-align:center;
width: 60px;
}
#navbar a:link, a:visited {
display: block;
width: 100%;
height: 50px;
font-size: 14px;
color: rgba(141,141,141,1);
text-decoration: none;
padding-top: 20px;
font-family: Raleway, sans-serif;
-moz-transition: background-color 0.3s ease;
-webkit-transition: background-color 0.3s ease;
transition: background-color 0.3s ease;
font-weight: 500;
-webkit-transition: all 0.3s linear;
-moz-transition: all 0.3s linear;
-ms-transition: all 0.3s linear;
-o-transition: all 0.3s linear;
transition: all 0.3s linear;
}
#navbar a:hover, a:active {
color:white;
background-color: #ff7200;
}
#active > a {
display: block;
color: white;
background-color: rgba(51,51,51,1);
}
现在,我在联系页面上有我的图标图片,这些图片链接到用户在Facebook,Twitter等上的个人资料,但是他们在我的导航栏处于活动状态时获得相同的背景。我怎么能改变它?
答案 0 :(得分:0)
我认为您的问题在于定义css的方式:
#navbar a:hover, a:active
应为#navbar a:hover, #navbar a:active