【问题标题】:Links aren't changing color when hovered over悬停时链接不会改变颜色
【发布时间】:2013-06-07 00:54:20
【问题描述】:

好的,我已经将这些链接设置了一段时间,并决定将悬停效果从使用下划线更改为颜色更改。我只是不明白为什么颜色不会改变。当我将 :hover text-decoration 更改为下划线时,它可以工作,但颜色只是表示我设置的正常链接颜色 (#747474)

.footerList {
    display: inline;
    padding: 0 9px 0 9px;
}
.footerList a:link {
    text-decoration: none;
    color: #747474;
    font-family: arial;
    font-size: 11px;
    font-weight: normal;
    padding: 0;
    margin: 0;
}
.footerList a:visited {
    text-decoration: none;
    color: #747474;
    font-family: arial;
    font-size: 11px;
    font-weight: normal;
    padding: 0;
    margin: 0;
}
.footerList a:hover {
    text-decoration: none;
    color: red;
    font-family: arial;
    font-size: 11px;
    font-weight: normal;
    padding: 0;
    margin: 0;
}
.footerList a:active {
    text-decoration: none;
    color: red;
    font-family: arial;
    font-size: 11px;
    font-weight: normal;
    padding: 0;
    margin: 0;
}

<ul id="footerUlContainer">
<li class="footerList"><a href="privacy.php">Privacy Policy</a></li>
<li class="footerList"><a href="tos.php">Terms of Service</a></li>
<li class="footerList"><a href="tou.php">Terms of Use</a></li>
<li class="footerList"><a href="tou.php">Businesses</a></li>
</ul>

【问题讨论】:

  • 尝试在颜色旁边使用 !important 进行悬停
  • 做一些调试。去掉所有其他样式,直到获得您想要的效果,然后开始重新引入其他样式。
  • 老实说,这对我有用 - Fiddle.

标签: html css


【解决方案1】:

也许你的风格被其他地方覆盖了,我建议使用chrome dev tools,无论如何试试这个:

    #footerUlContainer > .footerList a:hover {
    text-decoration: none;
    color: red;
    font-family: arial;
    font-size: 11px;
    font-weight: normal;
    padding: 0;
    margin: 0;
}

这是工作的demo

Aso 查看此blog 以更熟悉特异性规则

【讨论】:

  • 谢谢大家!我发现 footerUlContainer 覆盖了我的悬停影响
  • 很高兴你让它工作了:)!如果您觉得答案有用,请考虑投票并接受,这样它对其他用户仍然有用:)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2018-03-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-05-01
相关资源
最近更新 更多