繁体   English   中英

在其他页面上设置链接样式的正确方法

[英]Proper way of styling links on other page

我的主导航栏是这样的: 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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM