$ballSize: 20px;
$ballCount: 200;
body {
background: #eef;
height: 100vh;
overflow: hidden;
}
#ui {
.infinite {
position: absolute;
top: 50%;
left: 50%;
&_ball {
position: absolute;
top: 0;
left: 0;
width: $ballSize;
height: $ballSize;
transform: translate(-50%, -50%);
@for $i from 1 through $ballCount {
&:nth-child(#{$i}) {
margin-left: #{random(600) - 300}px;
animation: horizontal 1000ms infinite alternate cubic-bezier(0.545, 0.080, 0.520, 0.975) #{$i * 10}ms;
.inner {
width: $ballSize;
height: $ballSize;
margin-top: #{random(600) - 300}px;
transform: scale(#{random(10) / 10 + 0.2});
animation: vertical #{random(4000) + 4000}ms infinite alternate cubic-bezier(0.545, 0.080, 0.520, 0.975) #{$i * 10}ms;
background: rgba(random(255), random(255), random(255), 0.2);
border-radius: 999px;
}
}
}
}
}
}
@keyframes horizontal {
0% {
margin-left: -150px;
}
100% {
margin-left: 150px;
}
}
@keyframes vertical {
0% {
margin-top: -150px;
}
100% {
margin-top: 150px;
}
}
@keyframes scale {
0% {
transorm: translate(-50%, -50%) scale(0.5);
}
100% {
transorm: translate(-50%, -50%) scale(1.5);
}
}
View Compiled