I'm styling radio buttons (hiding them and using the labels as buttons), and trying to put border radius on first-child, but it does not respond as expected, or I'm doing it wrong.
How can I achieve left border radius on first label?
See it in action here > http://jsfiddle.net/sthrc57f/
HTML:
<input type="radio" name="radios" id="radioone" value="one">
<label for="radioone">radio 1</label>
<input type="radio" name="radios" id="radiotwo" value="two" checked="checked">
<label for="radiotwo">radio 2</label>
CSS:
input[type=radio] {
display:none;
}
input[type=radio] + label {
cursor: pointer;
display: inline-block;
margin: 0;
padding: 0.5em 2em 0.5em 2em;
background-color: #eeeeee;
color: #bbbbbb;
}
input[type=radio] + label:first-child {
border-top-left-radius: 7px;
border-bottom-left-radius: 7px;
-webkit-border-radius: 7px;
-webkit-border-bottom-left-radius: 7px;
-o-border-top-left-radius: 7px;
-o-border-bottom-left-radius: 7px;
-moz-border-top-left-radius: 7px;
-moz-border-bottom-left-radius: 7px;
}
input[type=radio]:checked + label {
background-color: green;
color: white;
}
input[type=radio]:checked + label:before {
content: "✓ ";
}
I have tried many combinations:
input[type=radio] label:first-child
input[type=radio]:first-child label
label:first-child
and more. No luck
I suspect maybe it's because the radio button itself is hidden so the first label can't be targeted like this?
EDIT: Solved. Here is the working edition: http://jsfiddle.net/sthrc57f/2/