body {
  font-family: Arial, sans-serif;
}

.container {
  perspective: 1000px;
  width: 200px;
  height: 200px;
  margin: 50px auto;
}

.cube {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  animation: rotateCube 5s infinite linear;
}

.face {
  position: absolute;
  width: 200px;
  height: 200px;
  line-height: 200px;
  text-align: center;
  font-size: 20px;
}

.front {
  background-color: #f00;
  transform: translateZ(100px);
}

.back {
  background-color: #00f;
  transform: rotateY(180deg) translateZ(100px);
}

.right {
  background-color: #0f0;
  transform: rotateY(90deg) translateZ(100px);
}

.left {
  background-color: #ff0;
  transform: rotateY(-90deg) translateZ(100px);
}

.top {
  background-color: #0ff;
  transform: rotateX(90deg) translateZ(100px);
}

.bottom {
  background-color: #f0f;
  transform: rotateX(-90deg) translateZ(100px);
}

@keyframes rotateCube {
  0% {
    transform: rotateY(0deg) rotateX(0deg);
  }

  100% {
    transform: rotateY(360deg) rotateX(360deg);
  }
}
