Creation of Custom Checkboxes and Radio Buttons
Posted By : Prince Kumar | 27-Sep-2017
In this blog, I will create custom Checkboxes and Radio buttons with pure CSS.
There are many other solutions available like jQuery-plugins to customize checkboxes and radio buttons but not so easy to implement.
I have simple and effective custom checkboxes and radio buttons with the minimum effort that works like an attraction in your project and highly accompaniment across the browsers, even works perfectly in internet explorer.
HTML
CSS
body {
font-family: Raleway;
}
.checkbox-custom, .radio-custom {
opacity: 0;
position: absolute;
}
.checkbox-custom, .checkbox-custom-label, .radio-custom, .radio-custom-label {
display: inline-block;
vertical-align: middle;
margin: 5px;
cursor: pointer;
}
.checkbox-custom-label, .radio-custom-label {
position: relative;
}
.checkbox-custom + .checkbox-custom-label:before, .radio-custom + .radio-custom-label:before {
content: '';
background: #bccffc;
border: 1px solid #94b2f7;
display: inline-block;
vertical-align: middle;
width: 20px;
height: 20px;
padding: 2px;
margin-right: 10px;
text-align: center;
}
.checkbox-custom:checked + .checkbox-custom-label:before {
background: #2b2e88;
box-shadow: inset 0px 0px 0px 4px #bccffc;
}
.radio-custom + .radio-custom-label:before {
border-radius: 50%;
}
.radio-custom:checked + .radio-custom-label:before {
background: #2b2e88;
box-shadow: inset 0px 0px 0px 4px #bccffc;
}
.checkbox-custom:focus + .checkbox-custom-label, .radio-custom:focus + .radio-custom-label {
outline: 1px solid #ddd; /* focus style */
}
Cookies are important to the proper functioning of a site. To improve your experience, we use cookies to remember log-in details and provide secure log-in, collect statistics to optimize site functionality, and deliver content tailored to your interests. Click Agree and Proceed to accept cookies and go directly to the site or click on View Cookie Settings to see detailed descriptions of the types of cookies and choose whether to accept certain cookies while on the site.
About Author
Prince Kumar
Prince is a sharp and intellectual UI Developer, he has a good knowledge of HTML. CSS, Jquery. His hobbies are reading books, listening music and net surfing,