-
-
Save Mottie/2996367 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] { | |
position: absolute; | |
top: -9999px; | |
left: -9999px; | |
} | |
label { | |
-webkit-appearance: push-button; | |
appearance: button; | |
display: inline-block; | |
margin: 60px 0 10px 0; | |
padding: 0 5px; | |
cursor: pointer; | |
} | |
/* Default State */ | |
div { | |
background: green; | |
width: 400px; | |
height: 100px; | |
line-height: 100px; | |
color: white; | |
text-align: center; | |
} | |
div.indicator { | |
width: 20px; | |
height: 20px; | |
display: inline-block; | |
} | |
/* Toggled State */ | |
input[type=checkbox]:checked + div, #toggle-all:checked ~ 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
<label for="toggle-all">I toggle all</label> | |
<input type="checkbox" id="toggle-all"> | |
<div class="indicator"></div><br> | |
<label for="toggle-1">I'm a toggle</label> | |
<input type="checkbox" id="toggle-1"> | |
<div>I'm controlled by toggle. No JavaScript!</div> | |
<label for="toggle-2">I'm a toggle</label> | |
<input type="checkbox" id="toggle-2"> | |
<div>I too am controlled by toggle. No JavaScript!</div> |
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
{"view":"split-vertical","fontsize":"100","seethrough":"","prefixfree":"1","page":"css"} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment