Cards✨ Premium

Parallax Layers

Three CSS layers stacked at distinct translateZ depths inside a preserve-3d context — hovering deepens each plane and reveals the depth illusion.

CSS3DParallax

You'll get access to the interactive demo with a free account.

This effect is part of Effect.Labs — 811 vanilla effects, some free, some premium. Cards has 41 effects, including 6 free. Explore the category →

3 usage examples

Premium product card — e-commerce showcase — Parallax Layers example 1

① Premium product card — e-commerce showcase

WhenA product grid or carousel on a landing page or online store — the user hovers to explore the item before clicking.
WhyThe three layers visually separate the product image (background), the price badge (middle), and the name (foreground): on hover, the title 'steps forward' toward the user, signalling interactivity and reinforcing quality perception without gimmicky animation.
Settingsperspective 800px for a more dramatic effect, layer-3 at translateZ(80px) / hover 95px for a prominent foreground, transition 0.4s ease-out for a smooth rise.
Landing page hero — application showcase panel — Parallax Layers example 2

② Landing page hero — application showcase panel

WhenA panel or card featured in the hero section of a SaaS homepage or mobile app landing page.
WhyThe 3D depth creates immediate visual hierarchy without a video or animated image: the app background stays anchored, the signature shifts, and the main title arrives toward the visitor. Result: a premium feel in pure CSS, zero JS dependency.
SettingsCard widened to 400×260px via CSS, perspective 1200px for a subtle effect, layers at translateZ(10/30/55px) for a non-linear progression between planes.
Article card — blog or magazine grid — Parallax Layers example 3

③ Article card — blog or magazine grid

WhenAn editorial grid where each article card has an interactive hover to encourage clicks.
WhySeparating the illustration (background), category tag (middle), and headline (foreground) creates narrative depth: on hover, the title comes toward the reader, signalling interactivity far better than a simple colour change or classic box-shadow.
SettingsTransition 0.25s for a snappy response, layer-3 at translateZ(70px) / hover 85px so the headline clearly detaches from the background illustration.

How it works

The .card-parallax-layers container combines two CSS properties that open a shared 3D space: transform-style: preserve-3d tells the rendering engine to place child elements inside the same three-dimensional volume (instead of flattening them), while perspective: 1000px sets the virtual eye distance. The lower this value, the more intense the perspective distortion.

Each child layer is placed at its own Z depth via translateZ: the background layer at 20 px, the mid layer at 40 px, and the foreground layer at 60 px. CSS perspective projection makes closer elements appear slightly larger — this scale differential between the three planes creates the depth illusion even without motion.

On :hover, each layer advances an additional 10 px in Z (20→30, 40→50, 60→70). The transition: transform .3s animates this change. Because the foreground layer is already the closest to the viewpoint, the perspective enlargement it undergoes during this advance is greater than the background's — that enlargement differential is what produces the parallax feeling between layers.

The effect is entirely declarative CSS — no JavaScript, no requestAnimationFrame, no mousemove listener. The card does not tilt based on cursor position: only the global hover triggers the Z transition. Result: zero JS computation cost, compatible with SSR and strict CSP.

Accessibility

  • prefers-reduced-motion absent from the code: CSS transitions always play on hover, even if the user has enabled 'Reduce Motion' in their OS. For an accessible implementation, wrap the transition declarations inside @media (prefers-reduced-motion: no-preference) { … }.
  • No ARIA roles (role, aria-label) are present on the card in the base code — layers are treated as decorative. If layer content is informative, add role="img" and an aria-label on the container.
  • The trigger is :hover only. A keyboard user tabbing to the card does not activate the 3D effect. To fix this, add .card-parallax-layers:focus-within .layer-N { transform: translateZ(…) } mirroring each :hover rule.
  • The layer-1 element has an opacity of 0.3 in the provided example — if it contains informative text or an icon, the contrast ratio may be insufficient (WCAG 1.4.3). Verify contrast or use this layer for decorative elements only.
  • The effect is purely visual and does not interfere with screen readers as long as text content stays in the normal DOM flow (layers are not aria-hidden in the base code).

Browser compatibility

Requires transform-style: preserve-3d and perspective — natively supported in all modern browsers since 2015.

Chrome 36+✓ Full
Firefox 16+✓ Full
Safari 9+✓ Full
Edge 79+✓ Full
Mobile iOS✓ Static (hover inactive)
Android Chrome✓ Static (hover inactive)

Without transform-style: preserve-3d support, layers render flat in DOM order — content stays readable and the card functional; the depth effect does not appear.

The code

HTML structure to paste into your page (CSS + JS available with a premium account):

index.html — structure
<div class="card-demo card-parallax-layers">
  <!-- Background layer: decorative element, texture, image (lowest translateZ) -->
  <span class="layer-1" style="position: absolute;">…</span>

  <!-- Mid layer: badge, price, category -->
  <span class="layer-2" style="position: absolute;">…</span>

  <!-- Foreground layer: main title, CTA (highest translateZ) -->
  <span class="layer-3">…</span>
</div>
🔒 Unlock the full code — from €2.99 the first month

Full HTML + CSS + JS, copy-paste ready — with hundreds of premium effects.

Customize

Options passed to the API or data-* attributes:

Option / propertyDefaultEffect
--bg-card #12121a CSS variable on :root — card background color. Accepts any CSS value (color, gradient via background-image, transparent).
--radius-xl 1rem CSS variable on :root — card corner radius.
perspective 1000px CSS property on .card-parallax-layers — virtual eye distance. 500 px = exaggerated dramatic effect; 1500 px+ = subtle and elegant perspective.
translateZ (layer-1) 20px / hover 30px Background layer depth, declared in .card-parallax-layers .layer-1 and :hover .layer-1. Increase the rest/hover gap to accentuate the animation.
translateZ (layer-2) 40px / hover 50px Mid layer depth in .card-parallax-layers .layer-2 and :hover .layer-2.
translateZ (layer-3) 60px / hover 70px Foreground layer depth in .card-parallax-layers .layer-3 and :hover .layer-3. This is the most visible plane — reserve it for your title or primary element.
transition .3s Transition duration on each layer. Add an explicit easing (e.g. ease-out, cubic-bezier(.2,.6,.3,1)) to customise the depth cinematics.

FAQ

No. The base code reacts only to the global hover via CSS :hover — all layers advance in Z without any rotation or tilt based on cursor position. To add tilt (rotX/rotY computed on mousemove), about ten lines of JS are enough: listen to mousemove on the card, normalise the cursor offset between -1 and 1, then apply rotateX(Ydeg) rotateY(Xdeg) on the container directly via style.transform.
Yes. Add a child element inside .card-parallax-layers and define its depth in CSS: .card-parallax-layers .layer-4 { transform: translateZ(80px); transition: transform .3s } with its corresponding hover state. There is no technical limit, but beyond 4 or 5 layers the perceived depth saturates visually and the closest layers may overflow the perspective container boundaries.
Not without adaptation. On mobile, :hover is rarely triggered by touch (behaviour depends on the browser and OS). The card displays statically with layers at their resting depth — no error, just no animation. To activate the effect on touch, add a touchstart/touchend JS handler that adds and removes an .is-hovered CSS class on the card, mirroring the :hover rules.