我的主导航栏是这样的: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等上的用户个人资料,但是当它们处于活动状态(如导航栏)时,它们具有相同的背景。我该如何改变?
最佳答案
我认为您的问题出在您定义CSS的方式中:#navbar a:hover, a:active
应该是#navbar a:hover, #navbar a:active
关于html - 在其他页面上设置链接样式的正确方法,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/25554809/