Pinned section with an evolving background in HTML and CSS
The key message stays pinned while the background changes colour and illustration at each scroll step. CSS sticky, a light script, stacked cards as fallback under prefers-reduced-motion.
Here is an excerpt of this component's code in HTML and CSS. The full code is free for members, ready to copy into your project.
This component also comes in
The code in HTML and CSS
<!doctype html>
<html lang="fr">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Section épinglée à fond évolutif</title>
<link rel="stylesheet" href="style.css" />
</head>
<body>
<main class="demo">
<section class="sefe" aria-labelledby="sefe-titre" data-sefe>
<div class="sefe__track">for (const root of document.querySelectorAll("[data-sefe]")) {
const steps = [...root.querySelectorAll("[data-sefe-step]")];
const cards = steps.map((step) => step.firstElementChild);
const backs = root.querySelector("[data-sefe-backs]");
const meter = root.querySelector("[data-sefe-meter]");
const reduced = window.matchMedia("(prefers-reduced-motion: reduce)");
// On a very short or heavily zoomed window the pinned message would cover the steps.
const tall = window.matchMedia("(min-height: 30rem)");
// Each background layer reuses the colours and the drawing of its step: nothing to keep in sync by hand.
const layers = steps.map((step, i) => {
const layer = document.createElement("div");
layer.className = "sefe__back";body {
display: grid;
grid-template-columns: minmax(0, 1fr);
place-items: center;
margin: 0;
min-height: 100vh;
background: var(--demo-bg);
color: var(--demo-text);
font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}
.demo {Free component: copy it freely, including for commercial projects.
Other features components in HTML and CSS
Features components in HTML and CSS
Three cards in saturated flat colours (yellow, pink, electric blue) with high-contrast text and a dark variant. Every colour pair is measured at AA: 5.5:1 at worst.
- Tailwind
- React
- CSS
- WordPress

Six features as frosted glass cards over a slowly drifting aurora mesh gradient. Pause button, still background under prefers-reduced-motion, CSS and a light script.
- Tailwind
- React
- CSS
- WordPress

A six-cell bento grid: key figures, SVG sparklines, a quote and icons. All the text is in the HTML and the animation is CSS only, with no script at all.
- Tailwind
- React
- CSS
- WordPress

A two-offer table: checked rows, a column highlighted from top to bottom and one call-to-action button per offer. Pure HTML and CSS, no script at all.
- Tailwind
- React
- CSS
- WordPress

A magazine-style article: title band, standfirst, drop cap, subheadings and a pull quote, set in three columns of equal height. Pure CSS, no script at all.
- Tailwind
- React
- CSS
- WordPress

A simulator that estimates the heating bill and the yearly savings in euros from the floor area, current energy and chosen works.
- Tailwind
- React
- CSS
- WordPress