-
-
Save meltedlilacs/7297710 to your computer and use it in GitHub Desktop.
Checkbox Hack
This file contains hidden or 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
/* Checkbox Hack */ | |
input[type=checkbox] { | |
display: none; | |
} | |
label { | |
cursor: pointer; | |
} | |
/* Default State */ | |
div { | |
background: green; | |
width: 400px; | |
height: 100px; | |
line-height: 100px; | |
color: white; | |
text-align: center; | |
} | |
/* Toggled State */ | |
input[type=checkbox]:checked ~ label div { | |
background: red; | |
} |
This file contains hidden or 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
<input type="checkbox" id="toggle"> | |
<label for="toggle"> | |
<div>I'm controlled by toggle. No JavaScript!</div> | |
</label> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment