Skip to content

Reveal on scroll in HTML and CSS

Steps that fade and slide into view as the page scrolls.

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

Open in a new tab

The code in HTML and CSS

index.html
<!doctype html>
<html lang="fr">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>Révélation au défilement</title>
    <link rel="stylesheet" href="style.css" />
  </head>
  <body>
    <main class="demo">
      <section class="efrd" data-efrd aria-labelledby="efrd-titre">
        <h2 class="efrd__title" id="efrd-titre">Votre site en quatre étapes</h2>
reveal.js
// Firefox does not support view timelines yet: replay the same range by hand.
if (!CSS.supports("animation-timeline: view()")) {
  const reduce = matchMedia("(prefers-reduced-motion: reduce)");
  document.querySelectorAll("[data-efrd]").forEach((root) => {
    const items = [...root.querySelectorAll("li")];
    // A plain fade stands in for the veil: its pseudo-element only exists where view timelines are supported.
    const animations = items.map((item) => {
      const animation = item.animate(
        [
          { opacity: 0, transform: "translateY(2.5rem) scale(0.97)" },
          { opacity: 1, transform: "none" },
        ],
style.css
:root {
  --efrd-text: #172033;
  --efrd-body: #4b5563;
  --efrd-card: #ffffff;
  --efrd-line: #e2e8f0;
  --efrd-num: #1d4ed8;
  --efrd-bg: #f1f5f9;
  --demo-bg: #f1f5f9;
  --demo-text: #172033;
}

@media (prefers-color-scheme: dark) {

Free component: copy it freely, including for commercial projects.

Visual effects components in HTML and CSS
  • Cards that fade in as they enter the screen, one after another in each row, without a line of JavaScript and with a static fallback.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • A translucent card with a saturated blur whose sharper edge refracts the colourful shapes drifting behind it, with an opaque fallback when transparency is reduced.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • A help block shaped like a conversation: bubbles, three animated typing dots and clickable quick replies that show your answers to frequent questions, frozen under prefers-reduced-motion.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • A paragraph whose words turn from grey to full ink, one by one, as the page scrolls, in pure CSS with a plain-text fallback.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • Four offset, translucent sine waves gently roll along the bottom of a section, each at its own pace.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component