Curtain Open
Two half curtains leave the edges, meet in the middle, the page changes behind them, then they open again on the new one: a theater scene change in 1.2 s, symmetrical, animated in scaleX only — CSS + 1.5 KB of JavaScript, curtains open at rest.
Updated
This effect is part of Effect.Labs — 846 vanilla effects, some free, some premium. Transitions has 52 effects, including 9 free. Explore the category →
3 usage examples



How it works
The curtains live in .curtain-container, a flex row laid over the whole .transition-preview screen (z-index: 10, transparent to clicks): two half-width panels, .curtain-left and .curtain-right, in a midnight-blue gradient (#1a1a2e → #0f172a). At rest, transform: scaleX(0) folds them against the edges, so page A stays fully visible (measured: 0% of the width covered in Chromium 151, Firefox 153 and WebKit 26.5).
On click, the container gets .animating; each panel plays its own 1.2 s ease-in-out animation (curtainLeft, curtainRight): scaleX(0) → 1 at 40%, held until 60%, then back to 0. transform-origin makes the symmetry: left center for the left panel, right center for the right one, so each unrolls from its edge and the two meet in the middle. Curtains closed from 0.48 s to 0.72 s; at 0.6 s, the script toggles .is-b on .transition-preview and the page changes behind them. Only transform is animated: no layout recalculation while closing.
Once open again, the curtains leave B on stage: .is-b stays set, and only the next click closes them to go back to A (in all three engines: 100% of the width covered at 0.6 s, 0% after reopening). Every rule starts from .co-stage, which avoids inheriting the .curtain-left of another component on the page, a curtain modal for instance.
Accessibility
- Reduced motion: the curtains do not close under
prefers-reduced-motion: reduce; the page changes in place with a 150 ms fade (measured: panels still, B visible in under 250 ms). - Keyboard and screen readers: the button is Fade Through's (fx-0685) and keeps focus while the curtains close; the curtains are empty
divs and the hidden page is not read. To announce a revealed result (a vote, a topic), addaria-live="polite"on.transition-preview.
Browser compatibility
CSS (@keyframes on transform: scaleX(), transform-origin, flexbox, inset) + 1.5 KB of JavaScript, no dependency. Measured in Chromium 151, Firefox 153 and WebKit 26.5: curtains open at rest, closed at swap time, page B held, back to A on the next click, focus kept, direct swap under reduced motion. inset sets the minimum versions: Chrome 87, Firefox 66, Safari 14.1.
Without JavaScript, the curtains stay open on page A and the button does nothing: provide a regular link to the next content. Without inset (Safari before 14.1), write top: 0; right: 0; bottom: 0; left: 0 on .transition-content and .curtain-container.
The code
HTML structure to paste into your page (the CSS + JS come with your purchase):
<div class="co-stage">
<div class="transition-preview">
<div class="transition-content old-content">Page A</div>
<div class="transition-content new-content">Page B</div>
<div class="curtain-container">
<div class="curtain-left"></div>
<div class="curtain-right"></div>
</div>
</div>
<button type="button" class="trigger-btn">Trigger Transition</button>
</div>
One-time payment, no subscription — the code is yours forever
Customize
Options passed to the API or data-* attributes:
| Option / property | Default | Effect |
|---|---|---|
Curtain material (CSS — .curtain-left, .curtain-right { background }) |
#1a1a2e → #0f172a gradient | Stripes (repeating-linear-gradient(90deg, #7a0f16 0 12px, #a3161f 12px 22px)) give a theater velvet; a border (border-right on the left one, border-left on the right one) marks the seam. |
Duration (CSS — animation: … 1.2s on both panels; JS — SWAP_AT, END_AT) |
1.2 s; swap at 600 ms, end at 1,200 ms | Change all four values together, SWAP_AT at half. 1.8 s for a solemn announcement. |
Time with curtains closed (CSS — 40% and 60% steps) |
0.24 s | 30% / 70% keeps the curtains closed for 0.48 s: the wait before the result becomes noticeable. |
Opening direction (CSS — transform-origin and scaleX) |
horizontal, from the left and right edges | For a curtain dropping from the fly loft, stack the panels (flex-direction: column, 50% height), switch to scaleY and to top center / bottom center. |
Content (HTML — .old-content, .new-content) |
"Page A" and "Page B" on two gradients | Any HTML. For a one-off reveal (a result), hide the button after the first click. |
FAQ
translateX) to reveal a dialog laid over the page. Curtain Open creates no window: it changes a screen's content in place, the curtains closing on the old one and opening on the new one. Dialog Curtain to show a message over the page; Curtain Open to replace one screen with another.width forces the browser to recompute layout on every frame; transform: scaleX() is computed separately, on the compositor, and stays smooth on a low-end screen. The flip side: a shrunk panel squashes what it contains (a pattern, some text). A velvet's vertical stripes compress with it, which looks like real fabric folding; a logo placed on the curtain would be distorted — put it on the page instead..new-content before calling stage.querySelector('.trigger-btn').click(). If the computation may take more than 0.6 s, wait for it to finish before triggering: otherwise the curtains would open on an empty page. A result arriving late can also be written during the 0.24 s the curtains are closed.