Created
April 8, 2013 18:40
-
-
Save arsdehnel/5339327 to your computer and use it in GitHub Desktop.
entire container, keeps perspective
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 the "hover" class is added */ | |
.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; | |
background: #999999; | |
} | |
/* 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; | |
} | |
/* back, initially hidden pane */ | |
.back { | |
transform: rotateY(180deg); | |
} |
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" id="container"> | |
<div class="flipper" id="flipper"> | |
<div class="front"> | |
Something on the front | |
</div> | |
<div class="back"> | |
Something else on the back | |
</div> | |
</div> | |
</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
container = document.getElementById("container"); | |
flipper = document.getElementById("flipper"); | |
container .onclick = function() { | |
if ( hasClass(container, "hover") ) { | |
container.className = container.className.replace(/\bhover\b/,''); | |
// Do stuff here | |
}else{ | |
container.className += " hover"; | |
} | |
return false; | |
} | |
function hasClass(el, cssClass) { | |
return el.className && new RegExp("(^|\\s)" + cssClass + "(\\s|$)").test(el.className); | |
} |
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
{"view":"split-vertical","fontsize":"100","seethrough":"","prefixfree":"1","page":"all"} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment