This is what I am trying to achieve - demo below.
Working:
- Hover on red div will set the background to red
- Hover on red div will set the background of the green div to green
- Hover on blue divs will set the background of the blue divs to blue
Not Working:
- Hover on blue divs will set/leave the background of the green div to white
Is there a CSS only solution that I have overlooked ? or do I have to resort to using JS for that ?
.root {
border: 1px solid red;
width: 300px;
height: 100px;
display: flex;
align-items: center;
justify-content: space-around;
}
.main {
border: 1px solid green;
width: 50px;
height: 50px;
background: white;
}
.secondary {
border: 1px solid blue;
width: 50px;
height: 50px;
background: white;
}
.root:hover {
background: red;
}
.root:hover .main,
.main:hover {
background: green;
}
.secondary:hover {
background: blue;
}
<div class="root">
<div class="main"></div>
<div class="secondary"></div>
<div class="secondary"></div>
</div>