Стилизация checkbox и radio на CSS
by Denis Tverdokhlebov
HTML
<label>
<input class="radio" type="radio" name="radio-test">
<span class="radio-custom"></span>
<span class="label">Lorem ipsum dolor sit amet, consectetur</span>
</label>
<label>
<input class="checkbox" type="checkbox" name="checkbox-test">
<span class="checkbox-custom"></span>
<span class="label">Lorem ipsum dolor</span>
</label>
CSS
.checkbox,
.radio {
display: none;
}
.checkbox-custom,
.radio-custom {
width: 20px;
height: 20px;
border: 2px solid #e7e7e6;
border-radius: 3px;
position: relative;
background: rgb(234, 236, 237);
background: -moz-linear-gradient(top, rgba(234, 236, 237, 1) 0%, rgba(249, 250, 250, 1) 100%);
background: -webkit-linear-gradient(top, rgba(234, 236, 237, 1) 0%, rgba(249, 250, 250, 1) 100%);
background: linear-gradient(to bottom, rgba(234, 236, 237, 1) 0%, rgba(249, 250, 250, 1) 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#eaeced', endColorstr='#f9fafa', GradientType=0);
}
.checkbox-custom,
.radio-custom,
.label {
display: inline-block;
vertical-align: middle;
}
.checkbox:checked+.checkbox-custom::before,
.radio:checked+.radio-custom::before {
content: "";
display: block;
position: absolute;
top: 3px;
right: 3px;
bottom: 3px;
left: 3px;
background: rgb(170, 169, 168);
background: -moz-linear-gradient(top, rgba(170, 169, 168, 1) 0%, rgba(255, 255, 255, 1) 100%);
background: -webkit-linear-gradient(top, rgba(170, 169, 168, 1) 0%, rgba(255, 255, 255, 1) 100%);
background: linear-gradient(to bottom, rgba(170, 169, 168, 1) 0%, rgba(255, 255, 255, 1) 100%);
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#aaa9a8', endColorstr='#ffffff', GradientType=0);
border-radius: 2px;
}
.radio-custom,
.radio:checked+.radio-custom::before {
border-radius: 50%;
}