Im trying to get the following to work, but it doesn’t work with the :hover selector:
.a, .b {
width: 100px;
height: 100px;
background: green;
margin: 25px;
}
.a:has(+ .b:hover) {
background: pink;
}
<div class="a"></div>
<div class="b"></div>
Without the :hover selector, it works in Chrome and on Firefox with the layout.css.has-selector.enabled flag enabled.
.a, .b {
width: 100px;
height: 100px;
background: green;
margin: 25px;
}
.a:has(+ .b) {
background: pink;
}
<div class="a"></div>
<div class="b"></div>
Is there any other way to get this to work?
The original intent is to have two lines of a table connected, so when one has a mouse over, both lines get highlighted.
Thank you in advance for any help.
>Solution :
Here’s one that works for setting both .a and .b to pink on hover of either.
.a, .b {
width: 100px;
height: 100px;
background: green;
margin: 25px;
}
.a:hover,
.a:has(+ .b:hover)
{
background: pink;
}
.b:hover,
.a:hover + .b
{
background: pink;
}
<div class="a"></div>
<div class="b"></div>
<div class="a"></div>
<div class="b"></div>