Skip to content

Instantly share code, notes, and snippets.

@crazzyguti
Forked from chriscoyier/dabblet.css
Last active September 10, 2018 18:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save crazzyguti/96917834f047bb78e38b2c7d970348f3 to your computer and use it in GitHub Desktop.
Save crazzyguti/96917834f047bb78e38b2c7d970348f3 to your computer and use it in GitHub Desktop.
Checkbox Hack
/* Checkbox Hack */
input[type=checkbox] {
position: absolute;
top: -9999px;
left: -9999px;
}
label {
-webkit-appearance: push-button;
-moz-appearance: button;
display: inline-block;
margin: 60px 0 10px 0;
cursor: pointer;
width:150px;
text-align:center;
padding:10px;
font:normal bold 20px/25px tahoma;
-moz-user-select: none;
-webkit-user-select: none;
-ms-user-select: none;
user-select: none;}
/* Default State */
div {
background: green;
width: 400px;
height: 100px;
line-height: 100px;
color: white;
text-align: center;
cursor: pointer;
}
/* Toggled State */
input[type=checkbox]:checked + div {
background: red;
}
<label for="toggle-1">I'm a toggle</label>
<input type="checkbox" id="toggle-1">
<div>I'm controlled by toggle. No JavaScript!</div>
{"view":"split-vertical","fontsize":"110","seethrough":"","prefixfree":"1","page":"css"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment