不希望导航栏链接在单击时改变颜色(悬停效果)
Don't want Navigation Bar links to change color when clicked (hover effect)
在 header 中单击我的其中一个导航时,它们会在单击后更改颜色。更奇怪的是,我的“主页”和“登录”按钮没有改变,但其余按钮却改变了。
我想知道如何消除这种效果,因为它会使我的文本变暗太多。 (让我更具体一点:我不想要你在文字后面看到的文字后面的灰色)
我的Html:
<h1 class = "name"><font color = "#3399FF"> Prog-Assist | </font><font size = "12" font color = "#4EA24E"> Where Collaboration is Welcomed</font></h1>
<div id = "header">
<div id = "gradient">
<div class = "nav">
<!-- container-fluid gives full width container of whole viewport -->
<div class = "container-fluid">
<ul id = "nav1" class= "text-left">
<li><a href = "main.html"><strong>Home</a></li>
<li><a href = "tech.html">Technologies</a></li>
<li><a href = "#">Programs</a></li>
<li><a href = "#">Blog</strong></a></li>
</ul>
<ul id = "nav2" class = "text-right">
<li><a href = "#"><strong>Sign In</a></li>
<li><a href = "#">Contact</strong></a></li>
</ul>
</div><!-- end container-fluid-->
</div><!--end nav-->
</div>
</div> <!-- end header -->
我的CSS:
h1.name{
/*font-family: Lato, 'Courier Bold', sanserif;*/
font-family: 'KOMIKAX_';
src: url(KOMIKAX_.tff);
font-weight: bold;
font-variant: small-caps;
font-size: 60px;
color: "red";
margin-left: 30px;
text-shadow: 0 0 1px black;
}
#header {
margin-left: 30px;
width:cover;
}
#gradient {
height: 65px;
border: 1px solid;
/* IE 10 */
background-image: -ms-linear-gradient(top, #81a8cb 0%, #1947D1 100%);
/* Firefox */
background-image: -moz-linear-gradient(top, #81a8cb, #1947D1);
/* Safari & Chrome */
background-image: -webkit-gradient(linear,left bottom,left top, color-stop(0, #1947D1),color-stop(1, #81a8cb));
box-shadow: inset 0 0 15px black;
}
#nav1 {
list-style: none;
}
#nav2 {
list-style: none;
}
.nav a {
text-decoration: none; /*remove underline*/
text-transform: uppercase;
color: white;
font-family: Rockwell, 'Courier Bold', serif;
font-size: 20px;
padding-bottom: 15px;
}
.nav li {
display: inline;
float: left;
padding: 10px;
}
.nav a:visited {
text-decoration: none;
color: white;
font-weight:bolder;
}
.nav a:hover {
text-decoration: none;
color: #A7D1A7;
}
.nav a:active {
text-decoration: none;
color: #19A3FF;
font-weight:bolder;
}
使用css伪类.
/* unvisited link */
header a:link {
color: #FF0000;
}
/* visited link */
header a:visited {
color: #00FF00;
}
/* mouse over link */
header a:hover {
color: #FF00FF;
}
/* selected link */
header a:active {
color: #0000FF;
}
css 伪class :visited就是要用
a:visited{ text-decoration:none; color:#fff;}
.nav a:visited, .nav a:hover{background-color:transparent; text-decoration:none}
如果这仍然不起作用,您可能有某种其他 CSS 在页面中覆盖它,那么您将使用 !important hack。
.nav a:visited, .nav a:hover{background-color:transparent !important; text-decoration:none}
a:visited {
text-decoration:none;
color:#fff;
}
在 header 中单击我的其中一个导航时,它们会在单击后更改颜色。更奇怪的是,我的“主页”和“登录”按钮没有改变,但其余按钮却改变了。
我想知道如何消除这种效果,因为它会使我的文本变暗太多。 (让我更具体一点:我不想要你在文字后面看到的文字后面的灰色)
我的Html:
<h1 class = "name"><font color = "#3399FF"> Prog-Assist | </font><font size = "12" font color = "#4EA24E"> Where Collaboration is Welcomed</font></h1>
<div id = "header">
<div id = "gradient">
<div class = "nav">
<!-- container-fluid gives full width container of whole viewport -->
<div class = "container-fluid">
<ul id = "nav1" class= "text-left">
<li><a href = "main.html"><strong>Home</a></li>
<li><a href = "tech.html">Technologies</a></li>
<li><a href = "#">Programs</a></li>
<li><a href = "#">Blog</strong></a></li>
</ul>
<ul id = "nav2" class = "text-right">
<li><a href = "#"><strong>Sign In</a></li>
<li><a href = "#">Contact</strong></a></li>
</ul>
</div><!-- end container-fluid-->
</div><!--end nav-->
</div>
</div> <!-- end header -->
我的CSS:
h1.name{
/*font-family: Lato, 'Courier Bold', sanserif;*/
font-family: 'KOMIKAX_';
src: url(KOMIKAX_.tff);
font-weight: bold;
font-variant: small-caps;
font-size: 60px;
color: "red";
margin-left: 30px;
text-shadow: 0 0 1px black;
}
#header {
margin-left: 30px;
width:cover;
}
#gradient {
height: 65px;
border: 1px solid;
/* IE 10 */
background-image: -ms-linear-gradient(top, #81a8cb 0%, #1947D1 100%);
/* Firefox */
background-image: -moz-linear-gradient(top, #81a8cb, #1947D1);
/* Safari & Chrome */
background-image: -webkit-gradient(linear,left bottom,left top, color-stop(0, #1947D1),color-stop(1, #81a8cb));
box-shadow: inset 0 0 15px black;
}
#nav1 {
list-style: none;
}
#nav2 {
list-style: none;
}
.nav a {
text-decoration: none; /*remove underline*/
text-transform: uppercase;
color: white;
font-family: Rockwell, 'Courier Bold', serif;
font-size: 20px;
padding-bottom: 15px;
}
.nav li {
display: inline;
float: left;
padding: 10px;
}
.nav a:visited {
text-decoration: none;
color: white;
font-weight:bolder;
}
.nav a:hover {
text-decoration: none;
color: #A7D1A7;
}
.nav a:active {
text-decoration: none;
color: #19A3FF;
font-weight:bolder;
}
使用css伪类.
/* unvisited link */
header a:link {
color: #FF0000;
}
/* visited link */
header a:visited {
color: #00FF00;
}
/* mouse over link */
header a:hover {
color: #FF00FF;
}
/* selected link */
header a:active {
color: #0000FF;
}
css 伪class :visited就是要用
a:visited{ text-decoration:none; color:#fff;}
.nav a:visited, .nav a:hover{background-color:transparent; text-decoration:none}
如果这仍然不起作用,您可能有某种其他 CSS 在页面中覆盖它,那么您将使用 !important hack。
.nav a:visited, .nav a:hover{background-color:transparent !important; text-decoration:none}
a:visited {
text-decoration:none;
color:#fff;
}