A Panel that flips around based on a button toggle
Created
February 11, 2015 01:25
-
-
Save ezos86/c603b51967fef8f74b8a to your computer and use it in GitHub Desktop.
Panel Flipper - Btn Toggle
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
<div class="flip-container" ontouchstart="this.classList.toggle('hover');"> | |
<div class="flipper"> | |
<div class="front"> | |
Front | |
</div> | |
<div class="back"> | |
back | |
</div> | |
</div> | |
</div> | |
<button class="btn">Flip</button> |
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
$('.btn').click(function(){ | |
$('.flip-container').toggleClass('hover'); | |
}); |
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
/* entire container, keeps perspective */ | |
.flip-container { | |
perspective: 1000; | |
} | |
/* flip the pane when hovered */ | |
.flip-container.hover .flipper, .flip-container.hover .flipper { | |
transform: rotateY(180deg); | |
} | |
.flip-container, .front, .back { | |
width: 320px; | |
height: 480px; | |
} | |
/* flip speed goes here */ | |
.flipper { | |
transition: 0.6s; | |
transform-style: preserve-3d; | |
position: relative; | |
} | |
/* hide back of pane during swap */ | |
.front, .back { | |
backface-visibility: hidden; | |
position: absolute; | |
top: 0; | |
left: 0; | |
} | |
/* front pane, placed above back */ | |
.front { | |
z-index: 2; | |
/* for firefox 31 */ | |
transform: rotateY(0deg); | |
background-color:#ccc; | |
} | |
/* back, initially hidden pane */ | |
.back { | |
transform: rotateY(180deg); | |
background-color:red; | |
} | |
/*.flip-container:hover .flipper, .flip-container.hover .flipper, .flip-container.flip .flipper { | |
transform: rotateY(180deg); | |
}*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment