JSFiddle - React, Tailwind, and code Playground
HTML
<div class="container">
<div class="cube">
<div class="front">
<div class="contents">
Front Content
</div>
</div>
<div class="left"></div>
<div class="right"></div>
<div class="top"></div>
<div class="bottom"></div>
<div class="back">
<div class="contents">
Back Content
</div>
</div>
</div>
</div>
CSS
.container {
margin: 50px auto;
position: relative;
-webkit-perspective: 1000;
width: 200px;
height: 200px;
}
.cube {
position: absolute;
width: 200px;
height: 200px;
-webkit-transform-style: preserve-3d;
-webkit-transition: -webkit-transform 1s;
}
.cube .contents {
position: absolute;
top: 10px;
left: 10px;
right: 10px;
bottom: 10px;
background: rgba(255,255,255,.4);
}
.cube:hover {
-webkit-transform: translateZ( -100px ) rotateY( -180deg ) rotateZ( -180deg );
}
.cube > div {
position: absolute;
width: 198px;
height: 198px;
border: 1px solid rgba(0,0,0,.1);
line-height: 180px;
font-weight: bold;
text-align: center;
background: rgba(0,0,0,.1);
-webkit-backface-visibility: hidden;
-webkit-box-shadow: 0 0 20px rgba(0,0,0,.2);
-webkit-transition: background 1.2s;
}
.cube:hover > div.left {
background: rgba(0,0,0,.05);
}
.cube:hover > div.bottom {
background: rgba(0,0,0,.05);
}
.cube .front { -webkit-transform: rotateY(0deg) translateZ( 100px ); }
.cube .back { -webkit-transform: rotateX(180deg) translateZ( 100px ); }
.cube .right { -webkit-transform: rotateY(90deg) translateZ( 100px ); }
.cube .left { -webkit-transform: rotateY(-90deg) translateZ( 100px ); }
.cube .top { -webkit-transform: rotateX(90deg) translateZ( 100px ); }
.cube .bottom { -webkit-transform: rotateX(-90deg) translateZ( 100px ); }