Advanced Checkbox Hack
Do you know the default checkbox hack?
HTML
<label for="toggle-1">Do Something</label>
<input type="checkbox" id="toggle-1">
<div>Control me</div>
CSS
input[type=checkbox] {
position: absolute;
top: -9999px;
left: -9999px;
}
div {
background: green;
}
input[type=checkbox]:checked ~ div {
background: red;
}
Problem
This hack is not working on (older) iOS and (up to date) Android.
Solution
How do we fix this? Read more about this in my article Advanced Checkbox Hack!
Written by Tim Pietrusky
Related protips
1 Response
@duiker101 You can create something with two states: not checked and checked in pure CSS and don't need to add JavaScript. For example a responsive menu and the hack opens/closes it.
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Css
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#