,

Subscribe to a CSS Cube Animation Tutorial #coding #html #programming #css

Posted by

Cube Animation using CSS

.container {
perspective: 800px;
}

.cube {
position: relative;
width: 200px;
transform-style: preserve-3d;
animation: rotate 5s infinite;
}

.face {
position: absolute;
width: 200px;
height: 200px;
background-color: rgba(0, 0, 255, 0.5);
line-height: 200px;
text-align: center;
font-size: 24px;
font-weight: bold;
}

.front {
transform: translateZ(100px);
}

.back {
transform: rotateY(180deg) translateZ(100px);
}

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

.right {
transform: rotateY(90deg) translateZ(100px);
}

.top {
transform: rotateX(90deg) translateZ(100px);
}

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

@keyframes rotate {
from { transform: rotateY(0); }
to { transform: rotateY(360deg); }
}

Cube Animation using CSS

In this article, we will create a simple cube animation using CSS.

Front
Back
Left
Right
Top
Bottom

0 0 votes
Article Rating
3 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
@pazhanikumar8584
9 months ago

pls pin the style in comment

@Aankit9000
9 months ago

Can you pin the code in the comment section?