I can't change the background of my div when an input is checked. When I check the second input the background of the div should change, possibly with an animation from left to right. Is there anyone who can help me? This is the html:
.first_switcher {
display: block;
margin: 0 auto;
height: 38px;
margin-top: 50px;
padding: 0px;
background: dimgray;
width: 200px;
border-radius: 38px;
position: relative;
}
.first_switcher__input2 {
display: none;
}
.first_switcher__input1 {
display: none;
}
.first_switcher__label1 {
float: left;
width: 100px;
font-size: 12px;
line-height: 38px;
color: #ffffff;
text-align: center;
cursor: pointer;
z-index: 10;
}
.first_switcher__label2 {
float: left;
width: 100px;
font-size: 12px;
line-height: 38px;
color: dimgray;
text-align: center;
cursor: pointer;
z-index: 10;
}
.first_switcher__input1:checked+.first_switcher__label1 {
color: white;
}
.first_switcher__input2:checked+.first_switcher__label2 {
color: white;
}
.first_switcher__input1:not(:checked)+.first_switcher__label1 {
color: dimgray;
}
.first_switcher__input2:checked+.first_switcher {
background: black;
}
<div class="first_switcher">
<input type="radio" name="balance" id="on" class="first_switcher__input1" checked/>
<label for="on" class="first_switcher__label1">ON</label>
<input type="radio" name="balance" id="off" class="first_switcher__input2"/>
<label for="off" class="first_switcher__label2">OFF</label>
</div>