In a container, two radio button inputs are placed. When the static button is checked, the containing div should be positioned
static, when the absolute button is checked, the container should be positioned absolute
. How to accomplish this JavaScript-free? Do I need additional markup?
div.container { border: 1px solid black; }
div.container input[id="static"]:checked + label {
background-color: aqua;
}
div.container input[id="absolute"]:checked + label {
background-color: green;
}
<div class="container">
<input id="static" type="radio" name="position" checked />
<label for="static">Static</label>
<input id="absolute" type="radio" name="position" />
<label for="absolute">Absolute</label>
</div>