JSFiddle - React, Tailwind, and code Playground
HTML
<body>
<div class="wrapper">
<div class="first"></div>
<div class="second"></div>
<div class="background"></div>
</div>
</body>
CSS
/*** To position .background ***/
.background {
position: absolute;
top: 0;
left: 0;
background: tomato;
height: 500px;
width: 500px;
z-index: -9999;
}
/*** To position .first and .second divs ***/
.first,
.second {
display: inline-block;
margin-left: 25px;
margin-top: 25px;
background: rgba(0,0,0,0.7);
width: 100px;
height: 100px;
}
/*** Hover effects on .first and .second divs ***/
.first:hover ~ .background {
background: yellow;
}
.second:hover ~ .background {
background: green;
}