I tried to change a label's color depending on the checked radio button, but couldn't reach it using CSS syntax because of the hierarchy of the HTML.
<div class="sliderContainer">
<div class="slides">
<input type="radio" name="radio-btn" id="radio1" checked>
<input type="radio" name="radio-btn" id="radio2">
<input type="radio" name="radio-btn" id="radio3">
</div>
</div>
<div class="navigation">
<label for="radio1" class="btnbar" id="label1"></label>
<label for="radio2" class="btnbar" id="label2"></label>
<label for="radio3" class="btnbar" id="label3"></label>
</div>
I'd tried to use ~
to reach the element and change a label's colors, but it only works with siblings. Is there a way to call an..."uncle" element? >,+, space and classes didn't work either
#radio1:checked ~ #label1 {
background: #6ab534;
}
#radio2:checked ~ #label2 {
background: #6ab534;
}
#radio3:checked ~ #label3 {
background: #6ab534;
}