效果
主要代码
.title {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background-clip: text;
-webkit-background-clip: text;
font-size: 28px;
}
.function-getShadows(@n) {
@shadows: ~`(function() {
var shadows = [];
for (var i = 0; i < @{n}; i++) {
shadows.push(
Math.round(Math.random() * 2000) + 'px ' +
Math.round(Math.random() * 2000) + 'px #fff'
);
}
return shadows.join(',');
})()`;
}
.random-size(@size) {
width: ~"@{size}px";
height: ~"@{size}px";
}
.function-auto() {
@initial-duration: 400s;
@count: 1000;
.loop(@counter, @duration, @count) when (@counter < 6) {
@random-size: @counter;
.layer@{counter} {
position: fixed;
.random-size(@random-size);
border-radius: 50%;
left: 0;
top: 0;
.function-getShadows(@count);
box-shadow: @shadows;
animation: moveUp @duration linear infinite;
&::after {
content: '';
position: fixed;
left: 0;
top: 100vh;
border-radius: inherit;
width: inherit;
height: inherit;
box-shadow: inherit;
}
}
.loop((@counter + 1), (@duration / 2), (@count / 2));
}
.loop(1, @initial-duration, @count);
}
.function-auto();
@keyframes moveUp {
to {
transform: translateY(-100vh);
}
}