Skip to content

Instantly share code, notes, and snippets.

@pwartbichler
Last active December 22, 2015 23:49
Show Gist options
  • Save pwartbichler/6549745 to your computer and use it in GitHub Desktop.
Save pwartbichler/6549745 to your computer and use it in GitHub Desktop.
CSS Styling for Checkboxes/Radio Buttons, works for IE9+ Look at the example: http://jsbin.com/AQoVENa/5/edit?html,css,output
input[type="checkbox"] {
position: absolute;
overflow: hidden;
clip: rect(0 0 0 0);
height: 1px;
width: 1px;
margin: -1px;
padding: 0;
border: 0;
}
input[type="checkbox"] + label {
position: relative;
}
input[type="checkbox"]:focus + label {
outline: 1px solid orange;
}
input[type="checkbox"] + label span.checkbox {
display: inline-block;
width: 15px;
height: 15px;
background: orange;
cursor: pointer;
position: absolute;
}
input[type="checkbox"] + label span.labeltext {
padding: 0 0 0 20px;
}
input[type="checkbox"]:checked + label span.checkbox {
background: green;
}
<input id="abc" type="checkbox" value="" />
<label for="abc">
<span class="checkbox"></span>
<span class="labeltext">Labeltext</span>
</label>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment