I have a UI that looks something like this
+---------------------------+
| |
| +--area1--+ +--area2--+ |
| | | | | |
| | | | | |
| +---------+ +---------+ |
| |
+---------------------------+
I'd like both area1 and area2 to show a particular style when either of them is hovered over. Right now if pointer is over area1 then I get
+---------------------------+
| |
| +--area1--+ +--area2--+ |
| |.........| | | |
| |....☝....| | | |
| +---------+ +---------+ |
| |
+---------------------------+
If pointer is over area2 I get
+---------------------------+
| |
| +--area1--+ +--area2--+ |
| | | |.........| |
| | | |....☝....| |
| +---------+ +---------+ |
| |
+---------------------------+
What I want is if the pointer is over either area1 OR area2 I both areas show their hover state
+---------------------------+
| |
| +--area1--+ +--area2--+ |
| |.........| |.........| |
| |....☝....| |.........| |
| +---------+ +---------+ |
| |
+---------------------------+
Is that possible with only CSS?
Here's some live HTML/CSS
* {
box-sizing: border-box;
}
html,body {
width: 100%;
height: 100%;
margin: 0;
}
.container {
display: flex;
justify-content: center;
align-content: center;
height: 100%;
}
.unrelatedcontainer {
width: 100%;
height: 100%;
border: 1px solid red;
}
.area1,
.area2 {
margin: 3em;
height: 80%;
border: 1px solid black;
display: flex;
justify-content: center;
align-content: center;
align-items: center;
}
.area1:hover,
.area2:hover {
background-color: green;
}
<div class="container">
<div class="unrelatedcontainer">
<div class="area1">
<div class="content">area1</div>
</div>
</div>
<div class="unrelatedcontainer">
<div class="area2">
<div class="content">area2</div>
</div>
</div>
</div>