HTML CODE
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Rotating Cube Animation</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="container">
<div class="cube">
<div class="face front"></div>
<div class="face back"></div>
<div class="face right"></div>
<div class="face left"></div>
<div class="face top"></div>
<div class="face bottom"></div>
</div>
</div>a
</body>
</html>
CSS CODE
body {
background: #000;
}
.container {
width: 200px;
height: 200px;
perspective: 800px;
margin: 15% auto;
}
.cube {
width: 100%;
height: 100%;
transform-style: preserve-3d;
animation: spin 20s linear infinite;
}
.face {
position: absolute;
width: 200px;
height: 200px;
background-size: cover;
border: 2px solid #da04c8;
border-radius: 10px;
}
.face.front {
transform: translateZ(100px);
}
.face.back {
transform: rotateY(180deg) translateZ(100px);
}
.face.right {
transform: rotateY(90deg) translateZ(100px);
}
.face.left {
transform: rotateY(-90deg) translateZ(100px);
}
.face.top {
transform: rotateX(90deg) translateZ(100px);
}
.face.bottom {
transform: rotateX(-90deg) translateZ(100px);
}
@keyframes spin {
0% {
transform: rotateX(0deg) rotateY(0deg);
}
100% {
transform: rotateX(360deg) rotateY(360deg);
}
}
Comments
Post a Comment