Created
March 8, 2022 11:27
-
-
Save web-elite/c44809e5eac889b94046d74ecec05d92 to your computer and use it in GitHub Desktop.
Convert checkboxes to select photos using Css only
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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