css - 选定的链接颜色

标签 css hyperlink

我试图让我的链接成为一种颜色(灰色),当鼠标悬停时它变成绿色,当单击时绿色保持不变。当单击一个新链接时,该链接变回灰色,另一个保持绿色等。我已经完成了所有工作,除了单击一个链接时保持绿色。有什么我能做的吗?谢谢!

<div id="navBar">
<font face="abeatbyKai">
<ul id="menu-list"> 
  <li><a class="menu_side" href="webpages/News.html" style="text-decoration: none" id="one">News</a></li> 
  <li><a class="menu_side" href="webpages/About Us.html" style="text-decoration: none" id="two">About Us</a></li> 
  <li><a class="menu_side" href="webpages/Gallery.html" style="text-decoration: none" id="three">Gallery</a></li> 
  <li><a class="menu_side" href="webpages/Affiliates.html" style="text-decoration: none" id="four">Affiliates</a></li> 
  <li><a class="menu_side" href="webpages/Biography.html" style="text-decoration: none" id="five">Biography</a></li> 
  <li><a class="menu_side" href="webpages/Contact.html" style="text-decoration: none" id="six">Contact</a></li>
</ul>
</font>
</div>




#menu {
width: 275px;
left: 0;
right: 0;
top:0;
bottom: 0;
position: absolute;
overflow: auto;
background: rgba(0,0,0,1);
border-right-width: 7px;
border-right-style: solid;
border-right-color: #000;
}
#navBar {
width: 225px;
height:260px;
left: 50px;
right: 0;
top:200px;
bottom: 0;
position: absolute;
overflow:hidden;
background:rgba(86,86,86,0);
font-size: 35px;
}
#menu-list {
padding:0; 
margin:0;

}
#menu-list li { 
list-style-type:none;
margin-bottom: 7px;
}

#menu-list a#one:link, a#two:link, a#three:link, a#four:link, a#five:link, a#six:link{
color: #5e5e5e;
}

#menu-list a#one:visited, a#two:visited, a#three:visited, a#four:visited, a#five:visited, a#six:visited {
color: #5e5e5e;
}

#menu-list a#one:active, a#two:active, a#three:active, a#four:active, a#five:active, a#six:active {
color: #07CB25;
}

#menu-list a#one:hover, a#two:hover, a#three:hover, a#four:hover, a#five:hover, a#six:hover{
color: #07CB25;
}

#main {
left: 275px;
right: 0;
top:0;
bottom: 0;
position: absolute;
overflow: auto;
background: rgba(16,16,16,0.6);
}

#gallery1 {
width:475px;
left:250px;
top: 500px;
position: absolute;

}
a {
outline: 0;
}

最佳答案

最简单的做法是将链接样式设置为灰色表示链接和已访问,绿色表示悬停和事件。然后,在每个单独的页面上,将“当前”类添加到表示当前页面的链接。当前类中的样式链接始终为绿色。

关于css - 选定的链接颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9028210/

相关文章:

css - Angular 7 - Autoprefixer 不适用于 CSS Grid

jquery - 下拉面板的名称

html - 使用 Zurb-Foundation 嵌套网格时出现问题

grails - grails g:link通过参数

javascript - 单击超链接时无法重定向和调用函数

css - 是否允许按钮显示 :grid?

javascript - 我的代码的平滑效果

excel - 通过在 EXCEL 列中查找文本转到特定单元格

javascript - 在新选项卡中打开链接但没有 _blank 方法

android - HTML <a/> 标签在Android中的实现