I have two adjacent selectors that I would like to use when paired over another. In the example below, two selectors should impact the other CSS when it hangs. This works great on hover .a, but not on a fall .b. I understand this because the DOM is read in order, and therefore CSS selectors cannot work in the opposite direction.
However, is there a workaround for jQuery (or any other suggestions) that can achieve this effect?
Here is the fiddle
Thanks.
HTML
<figure>
<div class="a">
A
</div>
<div class="b">
B
</div>
</figure>
CSS
.a {
width: 100px;
height: 100px;
background: red;
}
.b {
width: 100px;
height: 100px;
background: blue;
}
.a:hover ~ .b {
background: green;
}
.b:hover ~ .a {
background: green;
}
source
share