I made the tabs using radio button trick like this
Html
<div class="tabs">
<input type="radio" id="tab-1" name="tab-group-1" checked>
<label for="tab-1">Tab One</label>
<input type="radio" id="tab-2" name="tab-group-1">
<label for="tab-2">Tab Two</label>
</div>
then css:
.tabs label {
margin-left: -1px;
border: 1px solid;
padding: 0px 80px 0px 80px;
background: #ddd;
}
.tabs input[type=radio]:checked ~ .tabs label {
background: #fff;
border-bottom: 1px solid #fff;
}
The problem here is the style of label does not change when radio button is chosen. Can anyone help me to explain it, thanks
btw: I run code using IE 8. Does it support checked properties
Check following is the solution. Replace ~ with +.
.tabs label {
margin-left: -1px;
border: 1px solid;
padding: 0px 80px 0px 80px;
background: #ddd;
}
input[type="radio"]:checked + label {
background: #fff;
border-bottom: 1px solid #fff;
}
<div class="tabs">
<input type="radio" id="tab-1" name="tab-group-1" checked>
<label for="tab-1">Tab One</label>
<input type="radio" id="tab-2" name="tab-group-1"/>
<label for="tab-2">Tab Two</label>
</div>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With