Skip to content

Scroll Reveal Animations

Elements fade, slide, zoom or flip into view on scroll using IntersectionObserver and data-sr attributes, with stagger delays and reduced-motion support.

Also known as: scroll reveal, animate on scroll, fade in on scroll, scroll triggered animation

Scroll Reveal Animations live demo

Open in new tab

Pure CSS code (HTML, CSS, JS)

Scroll reveal animations in pure CSS with a small vanilla JavaScript helper: headings, step cards, stats and a call-to-action fade, slide, zoom or flip into place as they enter the viewport. It is a lightweight alternative to animation libraries for landing pages, feature sections, timelines and portfolios.

How it works

Every element that should animate gets a data-sr attribute with an effect name: fade-up, fade-down, fade-left, fade-right, zoom or flip. The CSS defines the hidden start state for each effect (an opacity of 0 and a starting transform stored in --sr-from). Adding .sr-visible plays the sr-reveal keyframes from that transform to the resting position, using --sr-duration and the ease-out curve in --sr-easing, so the motion settles gently.

On DOMContentLoaded the script finds every .sr-root, reads data-sr-threshold and data-sr-repeat, and creates one IntersectionObserver per root. It copies each data-sr-delay value (in milliseconds) into the --sr-delay custom property, which the CSS uses as animation-delay to stagger neighbouring items. Only then does it add .sr-ready to the root and immediately reveals items that are already on screen. The hidden states are all scoped under .sr-ready, so if JavaScript fails or IntersectionObserver is missing, the content simply stays visible. Other items receive .sr-visible when they intersect; in the default one-shot mode the observer then stops watching it.

The demo section is a dark navy "workflow" layout: a header, four numbered .sr-step cards that slide in from alternating sides, three .sr-stat counters that zoom in, and a gradient .sr-cta panel that flips up.

Customization

  • data-sr="fade-up" on any element inside .sr-root: switch to fade-left, fade-right, fade-down, zoom or flip to change the entrance effect.
  • data-sr-delay="200": delays that element's animation by 200 ms; increase the value step by step to stagger a group.
  • data-sr-threshold="0.2" on .sr-root: how much of an element (0 to 1) must be visible before it animates.
  • data-sr-repeat="true" on .sr-root: elements hide again when they leave the viewport and replay every time they return.
  • --sr-distance in style.css: how far items travel (default 2.5rem); smaller values give a subtler effect.
  • --sr-duration and --sr-easing: the speed and curve of every reveal (default 0.8s).
  • --sr-accent and --sr-accent-2: the amber-to-coral gradient on the step numbers, stat values and the call-to-action panel.

Use cases

  • Landing pages: headings and feature cards fade, slide, zoom or flip into place as they enter view
  • Process sections: numbered step cards slide in from alternating sides with staggered delays
  • Stats blocks: counters zoom in as the visitor scrolls to them
  • Portfolios and timelines: content stays visible if scripts fail or the visitor prefers reduced motion

Accessibility

The section is labelled by its heading with aria-labelledby, and the steps are an ordered list. The decorative step numbers are aria-hidden because the list already conveys order. Content is in the DOM from the start, so screen readers read it regardless of animation state. When the user has prefers-reduced-motion: reduce, the script does not hide anything and the CSS also forces every item to be visible with no animation. The call-to-action link has a clear :focus-visible outline.

Usage notes

You can place several .sr-root wrappers on one page; each has its own observer and settings. Avoid putting data-sr on elements that contain focusable controls you expect users to tab to before scrolling, or give them fade-up with a short distance.

Scroll Reveal Animations at a glance

Framework
Pure CSS
Code
HTML, CSS, JavaScript
JavaScript
Vanilla JavaScript, no jQuery
Dependencies
None
Layout
Responsive, works on mobile, dark design
Category
Scroll Animations
License
Free for personal and commercial use

Questions about this template

Can I use the Scroll Reveal Animations code for free?

Yes. You can copy or download the code and use it in personal and commercial projects, including client work. No sign-up is needed. Reselling it as part of a component library or template collection is not allowed; see the license.

How do I add it to my website?

There is nothing to install. Paste the HTML where the component should appear, add the CSS to your stylesheet and load the JavaScript before the closing </body> tag. Download HTML gives you a complete page with everything already linked.

Does it need jQuery or a JavaScript framework?

No. The script is plain vanilla JavaScript, so it works without jQuery, React or Vue. You can still use the markup inside those frameworks.

Does it work on mobile?

Yes. The layout adapts to small screens. Use the Mobile and Tablet buttons above the live demo to check it at phone and tablet width.

Requirements

No dependencies. Pure HTML, CSS and JavaScript.

Scroll Reveal Animations – free Pure CSS scroll animation template
Scroll Reveal Animations · free Pure CSS scroll animation template

More Scroll Animations

Horizontal Scroll Section – free Bootstrap 5 scroll animation template

Horizontal Scroll Section

Bootstrap 5 section that pins to the viewport and slides photo cards sideways as the page scrolls down, with a counter and progress bar.

Reading Progress Bar – free Tailwind CSS scroll animation template

Reading Progress Bar

Sticky Tailwind CSS reading progress bar with a gradient fill, clickable chapter markers, current section label, minutes left and a circular back-to-top indicator.