Starfield Night Sky
A twinkling starfield background with randomly scattered stars and a deep space gradient.
Starfield Night Sky
by FreeCsStyles Dev's
BackgroundsCinematic
🌐HTML/CSS
#stars#night#space#twinkle
Embed this component
Paste this snippet into any site — the design renders in a sandboxed iframe served from /embed/starfield-night-sky.
<iframe src="/embed/starfield-night-sky" sandbox="allow-scripts" loading="lazy" title="Starfield Night Sky" style="border:0;width:100%;height:480px;overflow:hidden"></iframe>Implementation code
Copy the HTML and CSS for Starfield Night Sky. The HTML and CSS variants are self-contained; framework variants assume that framework's project setup.
HTML
<div class="starfield-bg">
<span class="star s1"></span>
<span class="star s2"></span>
<span class="star s3"></span>
<span class="star s4"></span>
<span class="star s5"></span>
<span class="star s6"></span>
<span class="star s7"></span>
<span class="star s8"></span>
<div class="starfield-label">Starfield</div>
</div>CSS
.starfield-bg {
position: relative;
width: 100%;
height: 220px;
border-radius: 16px;
overflow: hidden;
background: linear-gradient(180deg, #050510 0%, #0a0a20 50%, #050510 100%);
}
.star {
position: absolute;
border-radius: 50%;
background: #fff;
animation: star-twinkle 3s ease-in-out infinite;
}
.s1 { top: 10%; left: 15%; width: 3px; height: 3px; box-shadow: 0 0 6px rgba(255,255,255,0.8); animation-delay: 0s; }
.s2 { top: 25%; left: 40%; width: 2px; height: 2px; box-shadow: 0 0 4px rgba(255,255,255,0.8); animation-delay: 0.5s; }
.s3 { top: 50%; left: 70%; width: 3px; height: 3px; box-shadow: 0 0 6px rgba(255,255,255,0.8); animation-delay: 1s; }
.s4 { top: 70%; left: 20%; width: 2px; height: 2px; box-shadow: 0 0 4px rgba(255,255,255,0.8); animation-delay: 1.5s; }
.s5 { top: 15%; left: 80%; width: 4px; height: 4px; box-shadow: 0 0 8px rgba(255,255,255,0.8); animation-delay: 0.3s; }
.s6 { top: 60%; left: 50%; width: 2px; height: 2px; box-shadow: 0 0 4px rgba(255,255,255,0.8); animation-delay: 2s; }
.s7 { top: 85%; left: 65%; width: 3px; height: 3px; box-shadow: 0 0 6px rgba(255,255,255,0.8); animation-delay: 0.8s; }
.s8 { top: 35%; left: 10%; width: 2px; height: 2px; box-shadow: 0 0 4px rgba(255,255,255,0.8); animation-delay: 1.2s; }
.starfield-label {
position: absolute;
inset: 0;
display: flex;
align-items: center;
justify-content: center;
font-size: 18px;
font-weight: 800;
color: rgba(255, 255, 255, 0.9);
}
@keyframes star-twinkle {
0%, 100% { opacity: 0.3; transform: scale(0.8); }
50% { opacity: 1; transform: scale(1.2); }
}Where Starfield Night Sky fits
- Hero Sections
- Space Themes
- Night Mode UI
Topics
- #stars
- #night
- #space
- #twinkle