JSFiddle - React, Tailwind, and code Playground
by Tan
HTML
<div class="panel">
<div class="cards">
<a class="front" href="#/front/link/"></a>
<div class="back"></div>
</div>
</div>
CSS
/* main container */
.panel {
width: 300px;
height: 300px;
margin: 100px auto;
position: relative;
-webkit-perspective: 1000;
}
/* prevent animation on hover */
.panel:not(:hover) .cards {
-webkit-animation: CardFlip 2s infinite linear;
-webkit-transform-style: preserve-3d;
}
/* increase front card size on hover */
.panel:hover .front {
-webkit-transform: scale(1.2, 1.2);
}
/* styling divs to be 100% fit */
.panel .cards,
.panel .front,
.panel .back {
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
}
/* cards container */
.panel .cards {
-webkit-transition: all 2s linear;
}
/* front card */
.panel .cards .front {
z-index: 2;
background: url('http://placehold.it/300x300/123');
-webkit-backface-visibility: hidden;
}
/* back card */
.panel .cards .back {
z-index: 1;
background: url('http://placehold.it/300x300/ddd');
-webkit-transform: scale(-1, 1);
}
@-webkit-keyframes CardFlip {
0% {
-webkit-transform: rotateY(0deg);
}
50% {
-webkit-transform: rotateY(180deg);
}
100% {
-webkit-transform: rotateY(360deg);
}
}