Reputation: 31
:hover
does not work. The background of div
is not changing when hovering on a
Code:
a:hover div {
background-color: yellow;
}
<a href="#">b</a>
<div>c</div>
Upvotes: 0
Views: 125
Reputation: 1076
You can use +
css selectore to select sibling of a.
Check this out for more child and sibling selectors : https://css-tricks.com/child-and-sibling-selectors/
Your code selects the child element. You should select the next sibling:
a:hover+div {
background-color: yellow;
}
<a href="#">b</a>
<div>c</div>
Upvotes: 5