Customizing Checkboxes with CSS


Hide the default checkbox and create a custom design with CSS and a label.

Source Code

.checkbox-custom {
    display: none;
}
.checkbox-custom + label {
    position: relative;
    padding-left: 25px;
    cursor: pointer;
}
.checkbox-custom + label:before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    width: 20px;
    height: 20px;
    background-color: #eee;
    border-radius: 4px;
}
.checkbox-custom:checked + label:before {
    background-color: #007bff;
}
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments