A Pen by Brett Diedrich on CodePen.
Created
January 15, 2014 00:32
-
-
Save Area51Brett/8428732 to your computer and use it in GitHub Desktop.
A Pen by Brett Diedrich.
This file contains 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-1">Do Something</label> | |
<input type="checkbox" id="toggle-1"> | |
<div id="over">Control me</div> | |
<div id="under"></div> | |
This file contains 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
input[type=checkbox] { | |
position: absolute; | |
top: -9999px; | |
left: -9999px; | |
/* For mobile, it's typically better to position checkbox on top of clickable | |
area and turn opacity to 0 instead. */ | |
} | |
/* Default State */ | |
div { | |
background: green; | |
width: 400px; | |
height: 100px; | |
line-height: 100px; | |
color: white; | |
text-align: center; | |
} | |
/* Toggled State */ | |
input[type=checkbox]:checked ~ #over { | |
/*background: red;*/ | |
opacity:0; | |
} | |
#under{ | |
position:absolute; | |
top:1; | |
z-index:-1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment