Short question: Why does the background-color
of .b
does not change when I hover? .a
?
CSS
.a {
color: red;
}
.b {
color: orange;
}
.a:hover .b {
background-color: blue;
}
HTML
<div id="wrap">
<div class="a">AAAA</div>
<div class ="b">BBBB</div>
</div>
try to understanding this example:
html code
when you hover on the box 1 than the box 3 will get black color
You shouldn't change a sibling's style when an event occurs on a different element. It's out of the context of CSS.
Use JavaScript to achieve this, for example:
You can use + selector
to apply the css for sibling element, or
for nested class.