پیشنمایش زنده
کد HTML
<div class="cube-loader">
<div class="cube-top"></div>
<div class="cube-wrapper">
<span style="--i:0" class="cube-span"></span>
<span style="--i:1" class="cube-span"></span>
<span style="--i:2" class="cube-span"></span>
<span style="--i:3" class="cube-span"></span>
</div>
</div>
کد CSS
.cube-loader {
position: relative;
width: 100px;
height: 100px;
transform-style: preserve-3d;
transform: rotateX(-30deg);
animation: animate 4s linear infinite;
}
@keyframes animate {
0% {
transform: rotateX(-30deg) rotateY(0);
}
100% {
transform: rotateX(-30deg) rotateY(360deg);
}
}
.cube-loader .cube-wrapper {
position: absolute;
width: 100%;
height: 100%;
transform-style: preserve-3d;
}
.cube-loader .cube-wrapper .cube-span {
position: absolute;
width: 100%;
height: 100%;
transform: rotateY(calc(90deg * var(--i))) translateZ(50px);
background: linear-gradient(
to bottom,
hsl(200, 80%, 50%) 0%,
hsl(200, 80%, 60%) 100%
);
}
.cube-top {
position: absolute;
width: 100px;
height: 100px;
background: hsl(200, 80%, 50%);
transform: rotateX(90deg) translateZ(50px);
transform-style: preserve-3d;
}
.cube-top::before {
content: '';
position: absolute;
width: 100px;
height: 100px;
background: hsl(200, 80%, 60%);
transform: translateZ(-100px);
filter: blur(10px);
box-shadow: 0 0 10px #333,
0 0 20px hsl(200, 80%, 60%),
0 0 30px #333,
0 0 40px hsl(200, 80%, 60%);
}