* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}
body {
    width: 100%;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: rgb(255, 0, 0);
    perspective: 15px;
    overflow: hidden;
}
.cube {
    position: relative;
    width: 500px;
    height: 500px;
    perspective: 100px;
    perspective-origin: center center;
    display: flex;
    align-items: center;
    justify-content: center;
    transform-style: preserve-3d;
 animation: animate 5s linear infinite;
}
@keyframes animate {
    0% {
        transform: rotateY(0deg) rotateY(0deg) rotateZ(0deg);
    }
    100% {
        transform: rotateY(360deg) rotateY(360deg) rotateZ(360deg);
    }
}

span {
    position: absolute;
    display: block;
    width: 100px;
    height: 100px;
    background-color:#f00;
}
.top {
    background-color: #0f0;
    transform: rotateX(90deg) translateZ(50px);
}
.back {
    background-color: #ff0;
    transform: translateZ(-50px);
}
.front {
    background-color: #00f;
    transform: translateZ(50px);
}
.right  {
    background-color: #0ff;
    transform: rotateY(-90deg) translateZ(50px);
}
.left {
    background-color: #f0f;
    transform: rotateY(90deg) translateZ(50px);
}