پیشنمایش زنده
کد HTML
<div class="loader">
<div class="cube"></div>
<div class="cube"></div>
<div class="cube"></div>
</div>
کد CSS
.loader {
position: relative;
display: flex;
justify-content: center;
align-items: center;
width: 150px;
height: 150px;
transform-style: preserve-3d;
perspective: 800px;
}
.cube {
position: absolute;
width: 50px;
height: 50px;
transform-style: preserve-3d;
animation: cube-fall 3s ease-in-out infinite;
}
.cube:nth-child(1) {
left: 0;
animation-delay: 0s;
background: linear-gradient(45deg, #ff3cac, #784ba0);
}
.cube:nth-child(2) {
left: 50px;
animation-delay: 0.3s;
background: linear-gradient(45deg, #00ffcc, #00b7eb);
}
.cube:nth-child(3) {
left: 100px;
animation-delay: 0.6s;
background: linear-gradient(45deg, #ffdb58, #ff6b6b);
}
.cube::before,
.cube::after {
content: "";
position: absolute;
width: 100%;
height: 100%;
background: inherit;
opacity: 0.7;
}
.cube::before {
transform: rotateX(90deg);
transform-origin: top;
}
.cube::after {
transform: rotateY(90deg);
transform-origin: left;
}
@keyframes cube-fall {
0% {
transform: translateY(-100px) rotateX(0deg) rotateY(0deg);
opacity: 0;
}
20% {
transform: translateY(0) rotateX(360deg) rotateY(360deg);
opacity: 1;
}
80% {
transform: translateY(0) rotateX(360deg) rotateY(360deg);
opacity: 1;
}
100% {
transform: translateY(100px) rotateX(720deg) rotateY(720deg);
opacity: 0;
}
}