JSFiddle - React, Tailwind, and code Playground
HTML
<div class="flip-container">
<div class="flipper">
<div class="front">
<h3>FRONT </h3>
<p> I'm front... </p>
</div>
<div class="back">
<h3> BACK </h3>
<p> I'm back... </p>
</div>
</div>
</div>
CSS
/* flip the pane when hovered */
.flip-container.flipped .flipper {
-webkit-transform: rotateY(180deg);
-moz-transform: rotateY(180deg);
-o-transform: rotateY(180deg);
transform: rotateY(180deg);
}
.flip-container, .front, .back {
width: 200px;
height: 200px;
}
.flip-container {
-webkit-perspective: 1000;
-moz-perspective: 1000;
-o-perspective: 1000;
perspective: 1000;
cursor: pointer;
position: absolute;
top:0;
left: 3px;
width: 200px;
overflow: hidden;
height: 200px;
z-index:2;
padding: 5px;
border-radius: 5px;
-webkit-border-radius: 5px;
border: 1px solid red;
}
/* front pane, placed above back */
.front {
z-index: 2;
}
h3 {
font-size: 1.1em;
font-weight: bold;
text-shadow: 0px 1px #eee;
}
/* back, initially hidden pane */
.back {
-webkit-transform: rotateY(180deg);
-moz-transform: rotateY(180deg);
-o-transform: rotateY(180deg);
transform: rotateY(180deg);
padding-top: 10px;
}
/* flip speed goes here */
.flipper {
-webkit-transition: 0.6s;
-webkit-transform-style: preserve-3d;
-moz-transition: 0.6s;
-moz-transform-style: preserve-3d;
-o-transition: 0.6s;
-o-transform-style: preserve-3d;
transition: 0.6s;
transform-style: preserve-3d;
position: relative;
border-radius: 5px;
-webkit-border-radius: 5px;
padding: 5px;
margin-left: 3px;
z-index: 3;
width: 160px;
height: 145px;
display:block;
}
/* hide back of pane during swap */
.front, .back {
-webkit-backface-visibility: hidden;
-moz-backface-visibility: hidden;
-o-backface-visibility: hidden;
backface-visibility: hidden;
width: 160px;
height: 145px;
position: absolute;
top: 0;
left: 0;
}
JavaScript
$('.flip-container').click(function () {
$(this).toggleClass("flipped");
});