Incorporating CSS allows for the utilization of the ~
selector when the input
precedes the boxes that need to be hidden/shown.
The label
element can be placed within the boxes and styled, potentially generating some checked boxes using the :after/:before pseudo elements.
The basic concept is as follows:
[type="checkbox"] {
position:absolute;
left:-999px;
}
:checked ~.div {
display:none;
}
#a:checked ~.div.a ,
#b:checked ~.div.b ,
#c:checked ~.div.c ,
#d:checked ~.div.d {
display:inline-block;
}
div, label {
margin:0.2em;
padding:0.5em;
display:inline-block;
border:solid;
}
<input id="a" type="checkbox"/>
<input id="b" type="checkbox"/>
<input id="c" type="checkbox"/>
<input id="d" type="checkbox"/>
<div class="div a">
<label for="a">a</label>
<p>box 1</p>
</div>
<div class="div b">
<label for="b">b</label>
<p>box 2</p>
</div>
<div class="div c">
<label for="c">c</label>
<p>box 3</p>
</div>
<div class="div d">
<label for="d">d</label>
<p>box 4</p>
</div>