A hillside town from sunrise to night, in pure SVG and CSS
Windows light up one by one at dusk, stars come out, a train crosses the valley. The whole day takes 12 seconds, and it is all SVG and CSS.
Motion loop
A whole day in 12 seconds
Sundry Millsundrymill.com/library
Download
The four skies, and the lamps
-
Dawn sky
-
Day sky
-
Dusk sky
-
Night sky
-
Window glow
The code
The trick: every colour runs on one 12 second clock
/* 0% sunrise, 12 to 35% day, 45% dusk, 56 to 86% night, 100% sunrise again */
.hill-far { animation: hill-far 12s linear infinite; }
@keyframes hill-far {
0%, 100% { fill: #e8b0a8; }
12%, 35% { fill: #a8d1c4; }
45% { fill: #b3708e; }
56%, 86% { fill: #2b386c; }
}
/* windows switch on one by one: each gets its own delay */
.w { animation: win 12s linear infinite; animation-delay: calc(var(--d, 0) * 50ms); }
@keyframes win {
0%, 100% { fill: #5d5a86; }
12%, 35% { fill: #9fd0e0; }
43% { fill: #3d3464; }
44.5% { fill: #ffd66e; }
86% { fill: #ffc95a; }
87.5% { fill: #1d2552; }
}
How to use it
- Every shape that changes colour uses the same 12 second duration and linear timing, with keyframes at the same percentages. That is what keeps the scene in step.
- The windows light up in turn because each one has a --d number and the delay is --d times 50 ms.
- To record it as a video, open the file full screen and screen record 12 seconds; the last frame matches the first.
When to use it
- A calm background for a hero section, a waiting screen, a stream's "starting soon" scene or a lo-fi music video.
- Learning CSS animation. It shows how one shared clock keeps dozens of shapes in step.
- Not behind body text. A sky that changes colour every few seconds keeps changing the contrast of anything on top of it.
A worked example: a "starting soon" scene for a stream
Twelve seconds of town that runs for as long as the stream is waiting.
- Download the HTML file and open it in a browser at the size of your stream, for example 1920 by 1080.
- In OBS, add it as a Browser source pointing at the file. It loops by itself, and the last frame matches the first, so there is no jump.
- Put your "starting soon" text in its own box with a solid background, not straight on the sky. The sky goes from dawn pink to night blue, and no single text colour clears 4.5:1 on all of them.
- To change the length of the day, change the 12s in every animation together. Every shape has to share the same duration, or the scene drifts apart.
Free to use in personal and commercial work. No credit needed, though a link back is always nice.