body {
background: #000;
}
.star {
position: absolute;
background: #fff;
border-radius: 50%;
animation: twinkle 1s infinite;
}
@keyframes twinkle {
50% {
opacity: 0.5;
}
}
window.onload = function() {
const numStars = 1000;
for (let i = 0; i < numStars; i++) {
const star = document.createElement('div');
star.classList.add('star');
star.style.top = Math.random() * 100 + 'vh';
star.style.left = Math.random() * 100 + 'vw';
star.style.width = Math.random() * 2 + 'px';
star.style.height = star.style.width;
star.style.animationDuration = Math.random() * 1 + 0.5 + 's';
document.body.appendChild(star);
}
};