
I've looked at several posts including the CSS Wizardry post, which give examples of showing/hiding elements based on the state of a checkbox. However, what I'm trying to do is a bit different and applying those techniques, I'm not having success.
I've got two divs (call them div 1 and div 2), and three radio buttons (A, B, and C). The behavior I want is to hide 2 when A is selected, hide 1 when B is selected, and hide both 1 and 2 when C is selected.
What I'm doing so far:
HTML
<input type="radio" name="attr_chartype" class="hide2" value="A" checked>Option A</input>
<input type="radio" name="attr_chartype" class="hide1" value="B">Option B</input>
<input type="radio" name="attr_chartype" class="hideboth" value="C">Option C</input>
<div class="details1">Blah</div>
<div class="details2">Blah</div>
CSS
input.sheet-hide1:checked ~ div.sheet-details1{
display: none;
}
input.sheet-hide2:checked ~ div.sheet-details2{
display: none;
}
Two issues:
- The first two buttons don't do anything as implemented
- I don't know how to specify both details1 & details2 in the CSS, together/at the same time for the third button's behavior
Any assistance is appreciated.