Skip to content

Instantly share code, notes, and snippets.

@arsdehnel
Created April 8, 2013 18:40
Show Gist options
  • Save arsdehnel/5339327 to your computer and use it in GitHub Desktop.
Save arsdehnel/5339327 to your computer and use it in GitHub Desktop.
entire container, keeps perspective
/* 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);
}
<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>
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);
}
{"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