JSFiddle - React, Tailwind, and code Playground

by Marc Malignan

HTML

<div id="main">
    <div class="cube">
        <div>FRONT</div>
        <div>LEFT</div>
        <div>RIGHT</div>
        <div>TOP</div>
        <div>BOTTOM</div>
    </div>
</div>

CSS

#main {
    position: absolute;
    top:0; right:0; bottom:0; left:0;
    background: #333;
    -webkit-perspective: 600;
}

.cube {
    position: absolute;
    top:50%; left:50%;
    width: 100px;
    height: 100px;
    margin: -50px 0 0 -50px;
    transform-style: preserve-3d;
    transition: all .5s;
}

.cube div {
    position: absolute;
    width:100%; height:100%;
    line-height: 100px;
    background: steelblue;
    border-radius: 4px;
    text-align: center;
    color: white;
    backface-visibility: hidden;
}
.cube div:nth-child(1) { transform: translateZ(50px); }
.cube div:nth-child(2) { transform: translateX(-50px) rotateY(-90deg); }
.cube div:nth-child(3) { transform: translateX(50px) rotateY(90deg); }
.cube div:nth-child(4) { transform: translateY(-50px) rotateX(90deg); }
.cube div:nth-child(5) { transform: translateY(50px) rotateX(-90deg); }