Custom Checkbox (CSS only)
A custom crossbrowser solution for CSS only checkboxes that don't rely on background images (although this is easily changeable, if desired).
by Dini Mer
HTML
<div class="custom-check">
<input class="custom-check-input" id="someCheck" name="someCheck" type="checkbox" />
<label class="custom-check-elem" for="someCheck"></label>
<label class="custom-check-label" for="someCheck">Checkbox-Label</label>
</div>
<div class="custom-radio">
<input class="custom-radio-input" id="someRadio-1" name="someRadio" type="radio" />
<label class="custom-radio-elem" for="someRadio-1"></label>
<label class="custom-radio-label" for="someRadio-1">Radiobutton Label 1</label>
</div>
<div class="custom-radio">
<input class="custom-radio-input" id="someRadio-2" name="someRadio" type="radio" />
<label class="custom-radio-elem" for="someRadio-2"></label>
<label class="custom-radio-label" for="someRadio-2">Radiobutton Label 2</label>
</div>
CSS
*, *:before, *:after {
-webkit-box-sizing: padding-box;
-moz-box-sizing: padding-box;
box-sizing: padding-box;
}
.custom-check, .custom-radio { margin: 20px; }
/* VISUALLY HIDE THE ORIGINAL CHECKBOX/RADIOBUTTON */
.custom-check input[type=checkbox],
.custom-radio input[type=radio] {
width: 1px;
height: 1px;
padding: 0;
border: 0;
margin: -1px;
clip: rect(0,0,0,0);
overflow: hidden;
position: absolute;
}
.custom-check-elem, .custom-radio-elem,
.custom-check-label, .custom-radio-label {
cursor: pointer;
vertical-align: middle;
}
/* CUSTOM CHECKBOX */
.custom-check-elem,
.custom-radio-elem {
display: inline-block;
position: relative;
margin-right: 4px;
border: 2px solid black;
width: 16px;
height: 16px;
}
/* CUSTOM RADIOBUTTON */
.custom-radio-elem {
-webkit-border-radius: 999px;
-moz-border-radius: 999px;
border-radius: 999px;
}
/* CUSTOM CHECKBOX/RADIOBUTTON CHECK */
.custom-check-elem:before,
.custom-radio-elem:before {
content: "\00d7";
display: none;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
font-family: verdana, arial, sans-serif;
font-size: 1.0em;
line-height: 1.0em;
color: black;
font-weight: bold;
text-align: center;
}
/* CUSTOM RADIOBUTTON CHECK */
.custom-radio-elem:before {
content: "\2022";
font-size: 1.25em;
line-height: 0.7em;
}
/* PSEUDO ELMENT CONTENT FOR CHECKED STATE */
.custom-check-input:checked + .custom-check-elem:before,
.custom-radio-input:checked + .custom-radio-elem:before { display: block; }
/* IE8: needs js-fallback for :checked, don't mix selectors! */
.custom-check-input.checked + .custom-check-elem:before,
.custom-radio-input.checked + .custom-radio-elem:before { display: block; }