Skip to content

Instantly share code, notes, and snippets.

@emiliorizzo
Created April 2, 2014 01:48
Show Gist options
  • Save emiliorizzo/9926610 to your computer and use it in GitHub Desktop.
Save emiliorizzo/9926610 to your computer and use it in GitHub Desktop.
Checkbox Hack
/* Checkbox Hack */
input[type=checkbox] {
display:none;
}
label {
display: inline-block;
cursor: pointer;
}
/* Default State */
div {
display: none;
}
/* Toggled State */
input[type=checkbox]:checked ~ div {
background: #e3f;
display:block;
}
:root input[type=checkbox]:checked + label{
font-weight:bold;
}
:root input[type=checkbox]:checked + label:after{
content: "<<";
}
:root input[type=checkbox] + label:after{
content: ">>";
}
label:hover{
color: #3bc;
font-weight:bold;
}
<ol>
<li>
<input type="checkbox" id="toggle-1">
<label for="toggle-1">I'm a toggle</label>
<div>I'm controlled by toggle. No JavaScript!</div>
</li>
<li>
<input type="checkbox" id="toggle-2">
<label for="toggle-2">I'm a toggle</label>
<div>
I'm controlled by toggle. No JavaScript!
<a href="http://google.com" target="_blank">test</a>
</div>
</li>
</ol>
{"view":"split-vertical","fontsize":"80","seethrough":"","prefixfree":"1","page":"all"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment