JSFiddle - React, Tailwind, and code Playground

by Tan

HTML

<div class="scene">
  <div class="cube">
    <div class="cube__face cube__face--front">front</div>

    <div class="cube__face cube__face--right">right</div>

  </div>
</div>

CSS

.scene {
  width: 200px;
  height: 200px;
  perspective: 600px;
  margin:auto;
}

.cube {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
}

.cube__face {
  position: absolute;
  width: 200px;
  height: 200px;
}

.cube__face--front  { background-color:#eeeeee;}
.cube__face--right  {  background-color:#dddddd;}

.cube__face--front  { transform: rotateY(  -45deg) translateZ(100px); }
.cube__face--right  { transform: rotateY( 45deg) translateZ(100px); }

.cube { transform: translateZ(-100px); }