body{
padding: 0;
margin: 0;
height: 100%;
}
.switch{
width: fit-content;
height: fit-content;
position: absolute;
top:0;
bottom: 0;
left: -50px;
right: 0;
margin: auto;
}
.track{
z-index: -1;
position: absolute;
top: 2px;
left: 1px;
background-color: #353b48;
height: 20px;
width: 48px;
border-radius: 14px;
}
.circle{
z-index: 0;
position: absolute;
height: 25px;
width: 25px;
background-color: #dcdde1;
border-radius: 50%;
pointer-events: none;
transition: .1s;
}
.checkbox{
position: absolute;
height: 25px;
width: 50px;
padding: 0;
margin: 0;
transition: .1s;
opacity: 0;
}
.checkbox:checked ~ .circle{
transform: translateX(100%);
}
.background_overlay{
position: absolute;
width: 100%;
height: 100vh;
background-color: red;
z-index: -2;
transition: .1s;
}
.checkbox:checked ~ .background_overlay{
background-color: green;
}
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="style.css">
<title></title>
</head>
<body>
<div class="switch">
<input type="checkbox" name="" value="" class="checkbox">
<div class="circle"></div>
<div class="track"></div>
</div>
<div class="background_overlay"></div>
</body>
</html>
So I wanna change the color of the div called "background_overlay" when checkbox is :active. The thing is, the background_overlay div is out of the switch div which contains the checkbox. I looked on internet but I can't figure out how to do this, there is no selector for this case. How could I achieve this please?