SolutionsCase StudiesAI ToolsResourcesAboutContact
Get Your Free AI Automation Audit Book a Free 30-Minute Strategy Call
Playground~/frontend Open editor

~/css/background-animations

7 CSS Background Animations

7 Pure CSSPublished 2026-10-05Free · no sign-up

Seven animated backgrounds for heroes and banners: a slowly flowing gradient, drifting aurora blobs, a twinkling starfield, a synthwave grid floor, layered SVG waves, rising bubbles and a dot matrix that breathes, all with no images and all switched off for reduced motion.

01. Flowing Gradient Background

BackgroundGradient

A large four-colour gradient slowly pans behind a hero, a calm movement that adds life without competing with the text. Only background-position animates, over fifteen seconds, and the text sits on top with enough contrast at every point.

View code
<section class="bga1"><h3>Ship faster</h3><p>Everything your team needs, in one place.</p></section>
.bga1 { width: 300px; max-width: 100%; box-sizing: border-box; padding: 40px 24px; border-radius: 18px; background: linear-gradient(120deg, #1e3a8a, #6d28d9, #9d174d, #0f766e) 0 50% / 400% 400%; color: #fff; text-align: center; font-family: Inter, system-ui, sans-serif; animation: bga1 15s ease infinite; }
.bga1 h3 { margin: 0 0 6px; font-size: 26px; } .bga1 p { margin: 0; color: #e0e7ff; }
@keyframes bga1 { 50% { background-position: 100% 50%; } }
@media (prefers-reduced-motion: reduce) { .bga1 { animation: none; } }

02. Aurora Blobs

BackgroundBlur

Three blurred colour blobs drift on slow, differently timed loops behind a dark panel, giving an aurora glow. filter: blur on the blobs, not the text, keeps the heading sharp, and the blobs are aria-hidden decoration.

View code
<section class="bga2"><span class="b1" aria-hidden="true"></span><span class="b2" aria-hidden="true"></span><span class="b3" aria-hidden="true"></span><h3>Northern lights</h3></section>
.bga2 { position: relative; overflow: hidden; display: grid; place-items: center; width: 300px; max-width: 100%; height: 200px; border-radius: 18px; background: #050816; font-family: Inter, system-ui, sans-serif; }
.bga2 span { position: absolute; width: 160px; height: 160px; border-radius: 50%; filter: blur(40px); opacity: .7; }
.bga2 .b1 { background: #22d3ee; top: -40px; left: -20px; animation: bga2a 12s ease-in-out infinite alternate; }
.bga2 .b2 { background: #a855f7; bottom: -60px; right: -20px; animation: bga2b 15s ease-in-out infinite alternate; }
.bga2 .b3 { background: #10b981; top: 30px; left: 90px; width: 110px; height: 110px; animation: bga2a 18s ease-in-out infinite alternate-reverse; }
.bga2 h3 { position: relative; margin: 0; color: #fff; font-size: 26px; }
@keyframes bga2a { to { transform: translate(80px, 40px) scale(1.2); } }
@keyframes bga2b { to { transform: translate(-90px, -30px) scale(.9); } }
@media (prefers-reduced-motion: reduce) { .bga2 span { animation: none; } }

03. Twinkling Starfield

BackgroundPattern

Two layers of tiny stars drawn with repeating radial gradients, each twinkling by fading its opacity on a different cycle. The whole sky is two pseudo-elements, with no images and no extra markup.

View code
<section class="bga3"><h3>Night sky</h3></section>
.bga3 { position: relative; overflow: hidden; display: grid; place-items: center; width: 300px; max-width: 100%; height: 200px; border-radius: 18px; background: radial-gradient(ellipse at bottom, #1e293b, #020617); font-family: Inter, system-ui, sans-serif; }
.bga3::before, .bga3::after { content: ""; position: absolute; inset: 0; background-image: radial-gradient(1.5px 1.5px at 20px 30px, #fff, transparent), radial-gradient(1px 1px at 70px 80px, #fff, transparent), radial-gradient(1.5px 1.5px at 130px 20px, #fff, transparent), radial-gradient(1px 1px at 160px 120px, #fff, transparent); background-size: 180px 140px; animation: bga3 3s ease-in-out infinite alternate; }
.bga3::after { background-position: 90px 60px; animation-duration: 4.5s; animation-delay: -2s; }
.bga3 h3 { position: relative; z-index: 1; margin: 0; color: #e2e8f0; font-size: 24px; }
@keyframes bga3 { from { opacity: .3; } }
@media (prefers-reduced-motion: reduce) { .bga3::before, .bga3::after { animation: none; } }

04. Moving Perspective Grid

BackgroundRetro

A neon grid floor recedes to the horizon and scrolls toward the viewer, the synthwave look. The grid is two linear-gradient line patterns on a plane tilted with rotateX, and the motion is a background-position loop exactly one grid square long.

View code
<section class="bga4"><h3>Retrowave</h3><div class="floor" aria-hidden="true"></div></section>
.bga4 { position: relative; overflow: hidden; width: 300px; max-width: 100%; height: 210px; border-radius: 18px; background: linear-gradient(#0c0420 40%, #3b0764); perspective: 220px; font-family: Inter, system-ui, sans-serif; }
.bga4 h3 { position: relative; z-index: 1; margin: 0; padding-top: 34px; text-align: center; color: #f0abfc; font-size: 28px; letter-spacing: .1em; text-shadow: 0 0 12px #d946ef; }
.bga4 .floor { position: absolute; left: -50%; right: -50%; bottom: -40px; height: 200px; background-image: linear-gradient(#e879f9 2px, transparent 2px), linear-gradient(90deg, #e879f9 2px, transparent 2px); background-size: 40px 40px; transform: rotateX(70deg); transform-origin: bottom; animation: bga4 1.2s linear infinite; -webkit-mask: linear-gradient(transparent, #000 60%); mask: linear-gradient(transparent, #000 60%); }
@keyframes bga4 { to { background-position: 0 40px; } }
@media (prefers-reduced-motion: reduce) { .bga4 .floor { animation: none; } }

05. Layered Waves

BackgroundSVG

Two wave shapes in an inline SVG slide sideways at different speeds along the bottom of a section. Each wave path is twice the width of the view and seamless, so translating it by half its width loops perfectly.

View code
<section class="bga5"><h3>Ocean breeze</h3><svg viewBox="0 0 1200 100" preserveAspectRatio="none" aria-hidden="true"><path class="w1" d="M0 60 Q150 20 300 60 T600 60 T900 60 T1200 60 V100 H0Z"/><path class="w2" d="M0 70 Q150 40 300 70 T600 70 T900 70 T1200 70 V100 H0Z"/></svg></section>
.bga5 { position: relative; overflow: hidden; width: 300px; max-width: 100%; height: 190px; border-radius: 18px; background: linear-gradient(#e0f2fe, #bae6fd); font-family: Inter, system-ui, sans-serif; }
.bga5 h3 { margin: 0; padding: 40px 24px; color: #0c4a6e; font-size: 24px; }
.bga5 svg { position: absolute; left: 0; bottom: 0; width: 200%; height: 70px; }
.bga5 .w1 { fill: #38bdf8; opacity: .7; animation: bga5 8s linear infinite; }
.bga5 .w2 { fill: #0284c7; animation: bga5 5s linear infinite reverse; }
@keyframes bga5 { to { transform: translateX(-50%); } }
@media (prefers-reduced-motion: reduce) { .bga5 path { animation: none; } }

06. Rising Bubbles

BackgroundParticles

Bubbles rise from the bottom of the panel at different sizes, speeds and starting points, all driven by one keyframe and three custom properties per bubble. The bubbles are list-free spans hidden from assistive technology.

View code
<section class="bga6"><h3>Sparkling water</h3><span style="--l:10%;--s:14px;--d:7s;--w:0s" aria-hidden="true"></span><span style="--l:30%;--s:8px;--d:5s;--w:-2s" aria-hidden="true"></span><span style="--l:55%;--s:20px;--d:9s;--w:-4s" aria-hidden="true"></span><span style="--l:75%;--s:10px;--d:6s;--w:-1s" aria-hidden="true"></span><span style="--l:88%;--s:16px;--d:8s;--w:-5s" aria-hidden="true"></span></section>
.bga6 { position: relative; overflow: hidden; display: grid; place-items: center; width: 300px; max-width: 100%; height: 210px; border-radius: 18px; background: linear-gradient(#0f766e, #042f2e); font-family: Inter, system-ui, sans-serif; }
.bga6 h3 { position: relative; margin: 0; color: #f0fdfa; font-size: 24px; }
.bga6 span { position: absolute; bottom: -30px; left: var(--l); width: var(--s); height: var(--s); border: 1.5px solid rgba(255,255,255,.6); border-radius: 50%; background: rgba(255,255,255,.08); animation: bga6 var(--d) linear var(--w) infinite; }
@keyframes bga6 { to { transform: translate(14px, -260px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .bga6 span { animation: none; display: none; } }

07. Pulsing Dot Matrix

BackgroundPattern

A dot grid made with one radial-gradient whose dot size swells and shrinks in a slow breath, behind a centred heading. Animating background-size moves every dot at once, and a radial mask fades the pattern out toward the edges.

View code
<section class="bga7"><h3>Built on data</h3></section>
.bga7 { box-sizing: border-box; position: relative; display: grid; place-items: center; width: 300px; max-width: 100%; height: 200px; border-radius: 18px; background: #fff; overflow: hidden; font-family: Inter, system-ui, sans-serif; border: 1px solid #e4e7ec; }
.bga7::before { content: ""; position: absolute; inset: 0; background: radial-gradient(circle, #6366f1 1.5px, transparent 2px) 0 0 / 18px 18px; -webkit-mask: radial-gradient(circle at center, #000, transparent 75%); mask: radial-gradient(circle at center, #000, transparent 75%); animation: bga7 4s ease-in-out infinite; }
.bga7 h3 { position: relative; margin: 0; padding: 8px 14px; border-radius: 10px; background: rgba(255,255,255,.85); color: #1e1b4b; font-size: 24px; }
@keyframes bga7 { 50% { background-size: 24px 24px; opacity: .6; } }
@media (prefers-reduced-motion: reduce) { .bga7::before { animation: none; } }

About these CSS Background Animations

Keep it slow

A background should never compete with the text on top. Loops of eight seconds or more, low contrast between colours and small movements keep it in the background where it belongs.

Check contrast at every moment

Text over a moving background must stay readable at the worst frame, not just the first. Test the lightest and darkest point of the animation against the text colour.

Cheap to animate

Move gradients with background-position, shapes with transform and fades with opacity. Blurred blobs are fine because the blur is applied once and the layer is only moved.

Pause when asked

Background motion is decoration, so it is the first thing to stop under prefers-reduced-motion. The still state should still look finished.

Frequently asked questions

Do animated backgrounds drain battery?

Continuous animation keeps the GPU busy. Pause it when the section is off screen with an IntersectionObserver if it is large.

Can I use these behind a whole page?

Yes; set the section to cover the viewport with position: fixed and a negative z-index, and keep the motion subtle.

Are any images used?

No. Every background is CSS gradients, pseudo-elements or a small inline SVG.