Container Scroll Reveal — Free HTML CSS JS Snippet

Container Scroll Reveal · Scroll · Plain HTML, CSS & JS · Live preview

Share & Support

What's included

Features

Sticky scroll stage
A tall section pins a 100vh window to animate in.
Normalized progress
One 0–1 value drives every property.
Flatten transform
rotateX eases from 32° to upright on scroll.
Scale-up reveal
The mockup grows as it stands up.
Top-edge pivot
transform-origin makes it rise, not spin.
Heading handoff
Title lifts and fades as the screen arrives.
rAF-throttled scroll
Passive, one update per frame.
Pure-CSS mockup
Image-free, crisp at any scale.

About this UI Snippet

Container Scroll Reveal — A Mockup That Rotates Flat on Scroll

Screenshot of the Container Scroll Reveal snippet rendered live

The container scroll reveal is the product-launch animation where a browser or dashboard mockup begins tilted back in 3D — as if lying on a table — and rotates upright while scaling toward you as the user scrolls, with the headline drifting up and fading as the screen takes over. This snippet builds the whole scroll-linked effect with plain HTML, CSS, and a compact vanilla JavaScript scroll handler.

A tall section with a sticky stage

The trick to scroll-linked animation is giving the scroll somewhere to happen. The .cs-section is 200vh tall, and inside it a .cs-sticky element is position: sticky; top: 0; height: 100vh — so it pins to the viewport and stays put while you scroll through the extra 100vh of the section. That pinned window is the stage on which the mockup animates, and the section's height is what gives you a full screen of scroll to drive the animation.

Mapping scroll to progress

Each frame, update() computes a progress value p from 0 to 1 by comparing the section's getBoundingClientRect().top against the total scrollable distance (offsetHeight - innerHeight). p is 0 when the section reaches the top of the viewport and 1 when you've scrolled to its bottom. Every animated property is then a simple function of p, which keeps the whole effect driven by one normalized number.

The flatten-and-grow transform

The mockup's tilt is rotateX(32 * (1 - p)), inside a perspective: 1200px stage — so at p = 0 it's tilted back 32° and at p = 1 it's perfectly upright. Simultaneously it scales from 0.86 to 1.0 (0.86 + p * 0.14), so the screen grows as it rises to face you. With transform-origin: center top, the rotation pivots from the top edge, so the mockup appears to stand up rather than spin in place. The heading, meanwhile, translates up by p * -60px and fades, handing focus to the product as it arrives.

Efficient, jank-free scroll handling

The scroll listener is { passive: true } and throttled with requestAnimationFrame behind a ticking flag, so no matter how many scroll events fire, the layout read and style writes happen at most once per frame. A resize listener re-runs the math because the scrollable distance depends on viewport height. This is the standard pattern for smooth scroll-driven effects without a library.

A pure-CSS mockup

The "dashboard" is built entirely from divs — a traffic-light title bar, a sidebar, list rows, and a row of gradient cards — so there are no image assets and it stays crisp at any scale. Swap the inner content for a real screenshot <img> and the scroll animation is unchanged.

Customizing it

Change the starting 32deg tilt and the 0.86 start scale for a more or less dramatic reveal, lengthen the section beyond 200vh to slow the animation, adjust how far the heading lifts, or replace the mockup with your own UI. Pair it with stacking scroll cards below or an animated gradient CTA to close the launch story.

Step by step

How to Use

  1. 1
    Paste HTML, CSS, and JSA heading and a tilted-back dashboard mockup pin to the viewport.
  2. 2
    Scroll downThe mockup rotates upright and scales toward you.
  3. 3
    Keep scrollingThe heading lifts away and fades as the screen takes over.
  4. 4
    Scroll back upThe animation reverses smoothly, linked to scroll.
  5. 5
    Slow it downIncrease the section height beyond 200vh.
  6. 6
    Swap in a screenshotReplace the CSS mockup with a real image.

Real-world uses

Common Use Cases

Product launches
Reveal an app before stacking scroll cards.
SaaS hero sections
Stand up a dashboard above a feature tabs showcase.
App marketing
Pair with a phone mockup elsewhere.
Landing stories
Lead into an animated gradient CTA.
Feature reveals
Introduce a new screen with motion.
Scroll-link demos
A reference for sticky scroll-progress mapping.

Got questions?

Frequently Asked Questions

The section is 200vh tall with a sticky 100vh child that pins to the viewport. Each frame, update() computes a 0–1 progress from the section's bounding-rect top against its scrollable distance. Every animated property — tilt, scale, heading offset — is a function of that single progress value, so the effect tracks scroll exactly.

Its transform-origin is center top, so the rotateX pivots around the top edge. As the angle eases from 32 degrees to 0, the bottom of the mockup swings up toward the viewer like a screen being raised, instead of rotating around its own middle. The simultaneous scale-up reinforces the sense of it rising to face you.

Yes. The scroll listener is passive and throttled with requestAnimationFrame behind a ticking flag, so the layout read and style writes run at most once per frame regardless of how many scroll events fire. A resize listener re-runs the math since the scrollable distance depends on viewport height.

Yes. The dashboard is built from plain divs only so the snippet needs no assets. Replace the inner .cs-screen content with an img of your product, keeping the .cs-frame wrapper. The rotate-and-scale scroll animation is applied to the frame, so it works identically with real imagery.

Keep the sticky section and run the scroll/resize handlers in a mount effect with cleanup, writing the frame and heading transforms via refs so scrolling doesn't trigger re-renders. Store the ticking flag in a ref. The CSS, including the sticky stage and perspective, ports directly. In Tailwind, use sticky and perspective utilities and apply the computed transforms through inline styles.