【问题标题】:Resetting visited colour重置访问的颜色
【发布时间】:2011-10-26 10:44:24
【问题描述】:

我需要在悬停时更改链接的颜色,但单击后返回原始颜色,我当前使用的代码会在单击链接后停止悬停更改。

<div id="nav1"><a href="clients.html">/Clients</a></div>

#nav1 {
    position: absolute;
    font-family: "Gill Sans";
    font-weight: 300;
    font-size: 10pt;
    letter-spacing: 0.15em;
    color: #fff;
    margin-top: 30px;
    margin-left: 20px;
}
#nav1 a:link {
    color: #fff;
    text-decoration: none;
}
#nav1 a:hover {
    color: #e8138b;
    text-decoration: overline;
}
#nav1 a:visited {
    color: #fff;
    text-decoration: none;
}

【问题讨论】:

    标签: html css hover hyperlink


    【解决方案1】:

    a:hover 的声明放在a:visited 之后。

    【讨论】:

      【解决方案2】:

      :hover 样式移到:visited 样式下方。它们具有相同的选择器特异性,因此最后一个样式对:hover:visited 的链接生效。

      顺便说一句,如果你想要一个单独的样式,你可以使用:hover:visited

      【讨论】:

      • 我只是在想象 IE 在看到多个伪元素时会破坏的所有不同方式。这就像在玻璃店里扔砖头一样。
      【解决方案3】:

      这应该可以解决问题...

      #nav1 a:link,
      #nav1 a:visited {
        color: #fff;
        text-decoration: none;
      }
      #nav1 a:hover {
        color: #e8138b;
        text-decoration: overline;
      }
      

      【讨论】:

        猜你喜欢
        • 2013-01-04
        • 2015-02-10
        • 2010-12-28
        • 1970-01-01
        • 2020-10-23
        • 1970-01-01
        • 2017-03-28
        • 2019-06-30
        • 2011-04-04
        相关资源
        最近更新 更多