CSS Checkbox Styling
Custom styles for checkboxes using CSS only
HTML
<input type="checkbox" class="checkbox-pandora" />
CSS
.checkbox-pandora {
position: relative;
width: 12px;
height: 12px;
margin: 0;
display: inline-block;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
-o-user-select: none;
user-select: none;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
outline: 0;
}
.checkbox-pandora:after {
content: '';
position: absolute;
display: block;
z-index: 1;
width: 12px;
height: 12px;
border: 1px solid #3c3c3c;
/*border-radius: 2px;*/
}
.checkbox-pandora[type=checkbox]:before {
background: #3c3c3c url("http://i.imgur.com/dR1TM0y.png");
background-size: 9px 9px;
background-repeat: no-repeat;
background-position: 1px 1px;
position: absolute;
left: 2px;
z-index: 2;
opacity: 0;
width: 100%;
height: 100%;
color: #3c3c3c;
}
.checkbox-pandora[type=checkbox]:checked:before {
content: '';
position: absolute;
top: 0px;
opacity: 1;
left: 0px;
border: 1px solid #3c3c3c;
/*border-radius: 2px;*/
}
JavaScript
// Some debug and IE stuff, not needed in a decent browser, but uncomment to check stuff
/*
$(function() {
$('input[type="checkbox"]').change(function() {
alert(this.checked);
});
// For IE
$('input[type="checkbox"]').change(function() {
$(this).toggleClass('checked');
});
});
*/