I want to obtain blinking dots one after one in one direction and then blinking have to go back, and all have to happen in the loop. I have created CSS code with Javascript according to first five dots. What can I do to make shorter all reqired code in CSS? Also I want to make not visible black backgrounds of the dots during blinking.
for (let i = 0; i < 40; i++) {
const dots = document.createElement("div");
document.body.appendChild(dots).classList.add("dots");
}
body {
background-color: #737373;
display: flex;
justify-content: space-evenly;
align-items: center;
min-height: 100vh;
overflow: hidden;
}
.dots {
background-color: rgb(0, 0, 0);
width: 20px;
height: 20px;
border-radius: 50%;
}
.dots:nth-of-type(1)::after {
content: "";
position: absolute;
width: 20px;
height: 20px;
border-radius: 50%;
animation: bright 0.3s linear;
background-color: rgb(255, 255, 255);
box-shadow: 0 0 3px 3px rgb(255, 255, 255),
0 0 5px 5px rgb(255, 255, 255), 0 0 12px 12px rgb(255, 255, 255);
opacity: 0;
animation-delay: 0s;
}
.dots:nth-of-type(2)::after {
content: "";
position: absolute;
width: 20px;
height: 20px;
border-radius: 50%;
animation: bright 0.3s linear;
background-color: rgb(255, 255, 255);
box-shadow: 0 0 3px 3px rgb(255, 255, 255),
0 0 5px 5px rgb(255, 255, 255), 0 0 12px 12px rgb(255, 255, 255);
opacity: 0;
animation-delay: 0.25s;
}
.dots:nth-of-type(3)::after {
content: "";
position: absolute;
width: 20px;
height: 20px;
border-radius: 50%;
animation: bright 0.3s linear;
background-color: rgb(255, 255, 255);
box-shadow: 0 0 3px 3px rgb(255, 255, 255),
0 0 5px 5px rgb(255, 255, 255), 0 0 12px 12px rgb(255, 255, 255);
opacity: 0;
animation-delay: 0.5s;
}
.dots:nth-of-type(4)::after {
content: "";
position: absolute;
width: 20px;
height: 20px;
border-radius: 50%;
animation: bright 0.3s linear;
background-color: rgb(255, 255, 255);
box-shadow: 0 0 3px 3px rgb(255, 255, 255),
0 0 5px 5px rgb(255, 255, 255), 0 0 12px 12px rgb(255, 255, 255);
opacity: 0;
animation-delay: 0.75s;
}
.dots:nth-of-type(5)::after {
content: "";
position: absolute;
width: 20px;
height: 20px;
border-radius: 50%;
animation: bright 0.3s linear;
background-color: rgb(255, 255, 255);
box-shadow: 0 0 3px 3px rgb(255, 255, 255),
0 0 5px 5px rgb(255, 255, 255), 0 0 12px 12px rgb(255, 255, 255);
opacity: 0;
animation-delay: 1s;
}
@keyframes bright {
0%,
100% {
opacity: 0;
}
50% {
opacity: 1;
}
}