Radio & Checkbox CSS
by Marty Thomas
HTML
<input type="radio" value="a" name="test">
<input type="radio" value="b" name="test">
<input type="checkbox" name="a" value="a">
<input type="checkbox" name="b" value="b">
CSS
/*****************************************************
****************** Radio *****************
******************************************************/
/* Hide Original Radio Button */
input[type="radio"] {
position: relative;
margin-top: 6px;
margin-right: 4px;
vertical-align: top;
border: none;
background-color: transparent;
-webkit-appearance: none;
appearance: none;
cursor: pointer;
}
/* Remove standard blue selection outline */
input[type="radio"]:focus {
outline: none;
}
/* New radio button */
input[type="radio"]:before,
input[type="radio"]:after {
content: "";
display: block;
width: 14px;
height: 14px;
border-radius: 50%;
-webkit-transition: 240ms;
-o-transition: 240ms;
transition: 240ms;
}
input[type="radio"]:before {
position: absolute;
left: 1px;
top: -2px;
background-color: red;
-webkit-transform: scale(0);
-ms-transform: scale(0);
-o-transform: scale(0);
transform: scale(0);
}
input[type="radio"]:after {
position: relative;
top: -3px;
border: 1px solid #E0E0E0;
}
/* New radio checked */
input[type="radio"]:checked:before {
-webkit-transform: scale(0.5);
-ms-transform: scale(0.5);
-o-transform: scale(0.5);
transform: scale(0.5);
}
input[type="radio"]:checked:after {
border-color: #E0E0E0;
}
/* New radio disabled */
input[type="radio"]:disabled:after,
input[type="radio"]:disabled:checked:after {
border-color: #F1F1F1;
}
input[type="radio"]:disabled:checked:before {
background-color: #F1F1F1;
}
/*****************************************************
**************** Checkbox ****************
******************************************************/
/* Hide Original Checkbox */
input[type="checkbox"] {
position: relative;
border: none;
margin-bottom: -4px;
-webkit-appearance: none;
appearance: none;
cursor: pointer;
}
/* Display New Checkox */
input[type="checkbox"] {
position: relative;
border: none;
margin-bottom: -4px;
...