Приветствую.
В примере я использовал input type="radio" для выбора "показать" "закрыть" некий блок. Как сделать так, чтобы активный radio изменил фон, т.е. lightgreen сменился на green, с красным получилось (цвета наоборот правда, но это не страшно), потому что он последующий элемент, а зеленый получается, как предыдущий элемент, так вот как выбрать чтобы предыдущий элемент менял фон при :checked? Спасибо!
body{z-index:10;positioin:relative;text-align:center;}
input{display:none;}/*радио кнопки*/
label[for="radio-1"]{background:lightgreen;}
label[for="radio-2"]{background:pink;}
label{
cursor:pointer;
border:1px solid #333;
padding:5px;
margin-top:20px;
display:inline-block;
}
label:hover{opacity:0.6;}
label:active{background:rgba(0,0,0,0.2);}
.block{
width:600px;
position:absolute;
top:80px;
left:28%;
}
#radio-1:checked ~ .block{display:block;} .block{display:none;}
#radio-1:checked ~ label{background:red;}
<label class="green" for="radio-1">OPEN<sup>(chckd)</sup></label>
<input type="radio" name="radio" id="radio-1" checked="checked">
<label class="red" for="radio-2">CLOSE</label>
<input type="radio" name="radio" id="radio-2">
<!-- -->
<!-- -->
<div class="block">
<fieldset>
<legend>HEADER</legend>
<h1>TEXT-HEADER #1
<strong>...some text</strong></h1>
</fieldset>
</div></code></pre>