【发布时间】:2016-11-10 10:56:44
【问题描述】:
我有这种情况,我觉得很奇怪,在哪里
a:hover {
color: #FD5454;
}
没用,但是
#feed h3 a:hover {
color: #FD5454;
}
确实如此。自从我广泛使用 CSS 以来已经有一段时间了,所以我不知道为什么。有人可以向我解释一下吗?这肯定是一个愚蠢的问题,但我自己无法弄清楚。提前谢谢!
编辑: 这是它目前正在影响的代码:
<div id="feed">
<h2>Follow us on instagram</h2>
<h3><a href="http://www.instagram.com/johndoe">@johndoe</a></h3>
</div>
以下是完整的样式规则:
a:link {
text-decoration: none;
color: white;
}
#feed {
text-align: center;
background: url("../img/Feed_bg.jpg") center no-repeat;
height: 100vh;
}
#feed h2 {
color: #789199;
padding-top: 5vh;
}
#feed h3 a {
text-decoration: none;
font-family: "Lato Light";
color: white;
}
/* This is working */
#feed h3 a:hover {
color: #FD5454;
}
/* This is not */
a:hover {
color: #FD5454;
}
【问题讨论】:
-
您是否有其他优先于 a:hover 的 CSS 规则?
-
没有。我还有一些使用 :hover 选择器的其他规则,但这些规则都会影响其他元素。
-
你能在你的问题中发布minimal reproducible example吗?
-
@j08691 当然,我的错。我以为这只是一个简单而愚蠢的问题。 :)
标签: css