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


 

Radio Buttons

Checkboxes

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 */
}
 

 

 

About Author

Author Image
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,

Request for Proposal

Name is required

Comment is required

Sending message..