Skip to content

Instantly share code, notes, and snippets.

@meltedlilacs
Forked from chriscoyier/dabblet.css
Last active December 27, 2015 08:39
Show Gist options
  • Save meltedlilacs/7297710 to your computer and use it in GitHub Desktop.
Save meltedlilacs/7297710 to your computer and use it in GitHub Desktop.
Checkbox Hack
/* 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;
}
<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