JSFiddle - React, Tailwind, and code Playground

by Tan

HTML

<div class="panel">
  <div class="cards">
   
    <div class="front"></div>
    <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 .cards {
  -webkit-animation: CardFlip 2s infinite linear;
  -webkit-transform-style: preserve-3d;
}



/* 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 {border-radius:500px;
  z-index: 2;
  background: url('http://placehold.it/300x300/123');
  -webkit-backface-visibility: hidden;
}

/* back card */
.panel .cards .back {border-radius:500px;
  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);
  }
}