Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save web-elite/c44809e5eac889b94046d74ecec05d92 to your computer and use it in GitHub Desktop.
Save web-elite/c44809e5eac889b94046d74ecec05d92 to your computer and use it in GitHub Desktop.
Convert checkboxes to select photos using Css only
//remove checkbox
input[type=checkbox]~label:after, input[type=checkbox]~span:after,input[type=checkbox]~label:before, input[type=checkbox]~span:before{
all:'';
}
#checkBoxInputs {
visibility: hidden;
}
//add image to input
#checkBoxInputs::after {
visibility: visible;
content: "";
color: red;
padding:50px;
background-color:green;
background-image: url(https://website.com/example.png);
background-repeat: no-repeat;
background-position: center;
background-size: contain;
cursor: pointer;
}
//style for checked input
#checkBoxInputs:checked::after {
border:2px solid green;
border-radius: 5px;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment