Source code:
<!DOCTYPE html>
<html lang=”en”>
<head>
<title>3D Rotating Cube Illusion</title>
<style>
body{
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
background: linear-gradient(135deg, #1d2b64, #f8cdda);
overflow: hidden;
}
.cube{
position: relative;
width: 200px;
height: 200px;
transform-style: preserve-3d;
animation: rotateCube 6s linear infinite;
}
.cube div{
position: absolute;
width: 100px;
height: 100px;
border: 1px solid white;
display: flex;
justify-content: center;
align-items: center;
font-size: 24px;
font-weight: bold;
background: rgba(0, 0, 0, 0.5);
}
.front{
transform: translateZ(50px);
background: #ff5733;
color: red ;
}
.back{
transform: rotateY(180deg) translateZ(50px);
background: #33ff57;
color: orange;
}
.left{
transform: rotateY(-90deg) translateZ(50px);
background: #5733ff;
color: blue;
}
.right{
transform: rotateY(90deg) translateZ(50px);
background: #faff33;
color: green;
}
.top{
transform: rotateX(90deg) translateZ(50px);
background: #ff33aa;
color: yellow;
}
.botttom{
transform: rotateX(-90deg) translateZ(50px);
background: #33faff;
color: white;
}
@keyframes rotateCube {
0%{
transform: rotateX(0deg) rotateY(0deg);
}
100%{
transform: rotateX(360deg) rotateY(360deg);
}
}
</style>
</head>
<body>
<div class=”cube”>
<div class=”front”>Front</div>
<div class=”back”>Back</div>
<div class=”left”>Left</div>
<div class=”right”>Right</div>
<div class=”top”>Top</div>
<div class=”botttom”>bottom</div>
</div>
</body>
</html>