How do you add 3D depth to a web page with CSS?

3D effects give flat interfaces a sense of depth by placing elements in a virtual space. In CSS this relies on the perspective property, transform-style: preserve-3d and 3D transforms such as rotateY() and translateZ(); WebGL takes over when a scene needs real lighting or hundreds of objects.

How to choose, performance and accessibility
  • Use CSS 3D for pieces people interact with: Card Flip 3D for a pricing or team card, Perspective Tilt for a product visual, 3D Carousel for a gallery; keep WebGL for immersive heroes.
  • Animate only transform and opacity so the browser can use the GPU, avoid stacking many 3D layers on mobile, and drop large rotations for prefers-reduced-motion.
  • Rotating Cube, Mouse Parallax Scene and Floating Shadows are free with their full code; the other effects on this page come with Premium.
Generator

Real 3D, not CSS perspective

The effects on this page fake depth with CSS. The SVG to 3D generator builds an actual volume: your logo is extruded, lit, it casts a shadow and you can grab it.

The preview and the image are free. The code comes for $4.90 (this generator, unlimited exports) or with lifetime access.

Open the generator
Front
Back
Right
Left
Top
Bottom

Rotating Cube

Interactive 3D cube that follows the mouse movement.

CSS 3D Interactive
Effect page →
View source code
HTML
<div class="fx-0001-root">
  <div class="demo-3d">
    <div class="cube-container" tabindex="0" role="group" aria-label="3D cube: point at it, or use the arrow keys">
      <div class="cube">
        <div class="cube-face front">Front</div>
        <div class="cube-face back">Back</div>
        <div class="cube-face right">Right</div>
        <div class="cube-face left">Left</div>
        <div class="cube-face top">Top</div>
        <div class="cube-face bottom">Bottom</div>
      </div>
    </div>
  </div>
</div>
CSS
.fx-0001-root,
.fx-0001-root *,
.fx-0001-root *::before,
.fx-0001-root *::after {
  box-sizing: border-box
}

.fx-0001-root {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 250px;
  overflow: hidden;
  position: relative;
  background: rgb(26, 26, 36);
  color: rgb(255, 255, 255);
  font-family: sans-serif;
}

.demo-3d {
  width: 280px;
  height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.cube-container {
  width: 100px;
  height: 100px;
  perspective: 600px;
  /* A finger turns the cube instead of scrolling the page (100 px area). */
  touch-action: none;
  outline: none;
}

.cube-container:focus-visible {
  outline: 2px solid #a5b4fc;
  outline-offset: 22px;
  border-radius: 6px;
}

.cube-container:focus-visible .cube-face {
  border-color: rgba(255, 255, 255, 0.9);
}

.cube {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transform: rotateX(-20deg) rotateY(-30deg);
  transition: transform 0.1s ease-out;
}

.cube-face {
  position: absolute;
  width: 100px;
  height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  backface-visibility: visible;
}

.cube-face.front {
  background: rgba(99, 102, 241, 0.8);
  transform: translateZ(50px);
}

.cube-face.back {
  background: rgba(139, 92, 246, 0.8);
  transform: rotateY(180deg) translateZ(50px);
}

.cube-face.right {
  background: rgba(217, 70, 239, 0.8);
  transform: rotateY(90deg) translateZ(50px);
}

.cube-face.left {
  background: rgba(6, 182, 212, 0.8);
  transform: rotateY(-90deg) translateZ(50px);
}

.cube-face.top {
  background: rgba(16, 185, 129, 0.8);
  transform: rotateX(90deg) translateZ(50px);
}

.cube-face.bottom {
  background: rgba(244, 63, 94, 0.8);
  transform: rotateX(-90deg) translateZ(50px);
}

/* Reduced motion: the cube no longer follows the pointer and stays at its three-quarter pose;
   the arrow keys still turn it, in 15° steps, with no transition. */
@media (prefers-reduced-motion: reduce) {
  .fx-0001-root .cube { transition: none }
}
JavaScript
(function() {
  // Rotating Cube: the cube turns toward the pointer (mouse or finger) and goes back to its three-quarter pose when it leaves.
  // With the keyboard (Tab), the arrow keys turn it in 15° steps; Escape puts it back at three-quarters.
  // One cube per .fx-0001-root: several copies can live on the same page.
  var reduce = window.matchMedia('(prefers-reduced-motion: reduce)');
  var REST_X = -20, REST_Y = -30;

  document.querySelectorAll('.fx-0001-root').forEach(function(root) {
    var cube = root.querySelector('.cube');
    var zone = root.querySelector('.cube-container');
    if (!cube || !zone) return;
    var keyX = REST_X, keyY = REST_Y;

    function turn(x, y) {
      cube.style.transform = 'rotateX(' + x + 'deg) rotateY(' + y + 'deg)';
    }

    function rest() {
      keyX = REST_X;
      keyY = REST_Y;
      turn(REST_X, REST_Y);
    }

    function follow(e) {
      if (reduce.matches) return; // reduced motion: no tilt following the pointer
      var rect = zone.getBoundingClientRect();
      var x = e.clientX - rect.left - rect.width / 2;
      var y = e.clientY - rect.top - rect.height / 2;
      turn(-y / 5, x / 5);
    }

    zone.addEventListener('pointermove', follow);
    zone.addEventListener('pointerdown', follow);
    zone.addEventListener('pointerleave', rest);

    zone.addEventListener('keydown', function(e) {
      if (e.key === 'Escape') { rest(); return; }
      var step = { ArrowUp: [15, 0], ArrowDown: [-15, 0], ArrowLeft: [0, -15], ArrowRight: [0, 15] }[e.key];
      if (!step) return;
      e.preventDefault(); // the arrow keys turn the cube, they do not scroll the page
      keyX += step[0];
      keyY += step[1];
      turn(keyX, keyY);
    });
    zone.addEventListener('blur', rest);
  });
})();

Card Flip 3D

Full card flip with realistic 3D effect.

CSS 3D Hover

Perspective Tilt

Element that tilts in 3D based on cursor position.

JS 3D Mouse

Folding Panel

A flap that lifts on hover, keyboard focus or touch to reveal a hidden half.

CSS 3D Fold

3D Button Press

Button with realistic 3D press effect.

CSS 3D Button

Layered Parallax 3D

Multiple layers with 3D depth effect.

JS 3D Parallax

Rotating Text

A gradient word that sways in 3D and spins a full turn on hover.

CSS 3D Text

3D Menu Stack

Stacked menu with depth effect on hover.

CSS 3D Menu

Isometric Grid

Isometric grid with interactive 3D cubes.

CSS 3D Isometric

Cube Auto-Rotation

3D cube with continuous automatic rotation.

CSS 3D Auto

Parallax Depth Layers

Stacked layers with 3D depth effect.

CSS 3D Depth

Fold Effect Card

Card that folds inward on hover.

CSS 3D Fold

Door Open Effect

3D door that opens to reveal the content.

CSS 3D Door

Page Turn Effect

A notebook whose pages turn one after another on hover, keyboard focus or touch.

CSS 3D Book

Prism Rotation

Six translucent panels in a hexagonal ring that turn and cross like a lantern.

CSS 3D Prism

Floating Elements 3D

Floating elements with animated 3D rotation.

CSS 3D Float

3D Button Press V2

3D button with perspective press effect.

CSS 3D Button

Shadow Perspective

Card with realistic 3D shadow that reacts on hover.

CSS 3D Shadow

Mouse Parallax Scene

Multi-layered scene (stars, moon, mountains, trees) reacting to cursor at different speeds.

JS Mouse Parallax
Effect page →
View source code
HTML
<div class="fx-0021-root">
  <div class="parallax-scene" data-parallax-scene>
    <div class="parallax-layer" data-depth="0.1">
      <div class="parallax-stars">
        <span class="parallax-star" style="top:10%;left:15%"></span>
        <span class="parallax-star" style="top:20%;left:75%"></span>
        <span class="parallax-star" style="top:35%;left:45%"></span>
        <span class="parallax-star" style="top:15%;left:90%"></span>
        <span class="parallax-star" style="top:50%;left:25%"></span>
        <span class="parallax-star" style="top:8%;left:55%"></span>
        <span class="parallax-star" style="top:42%;left:80%"></span>
        <span class="parallax-star" style="top:28%;left:10%"></span>
      </div>
    </div>
    <div class="parallax-layer" data-depth="0.25" style="display:flex;align-items:flex-start;justify-content:flex-end;padding:60px 90px 0 0;">
      <div class="parallax-moon"></div>
    </div>
    <div class="parallax-layer" data-depth="0.4">
      <div class="parallax-mountains">
        <div class="parallax-mountain mountain-1"></div>
        <div class="parallax-mountain mountain-2"></div>
        <div class="parallax-mountain mountain-3"></div>
        <div class="parallax-mountain mountain-4"></div>
      </div>
    </div>
    <div class="parallax-layer" data-depth="0.6">
      <div class="parallax-trees">
        <div class="parallax-tree tree-sm"></div>
        <div class="parallax-tree tree-lg"></div>
        <div class="parallax-tree tree-md"></div>
        <div class="parallax-tree tree-sm"></div>
        <div class="parallax-tree tree-lg"></div>
        <div class="parallax-tree tree-md"></div>
        <div class="parallax-tree tree-sm"></div>
      </div>
    </div>
  </div>
</div>
CSS
.fx-0021-root,
.fx-0021-root *,
.fx-0021-root *::before,
.fx-0021-root *::after {
  box-sizing: border-box
}

.fx-0021-root {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 250px;
  overflow: hidden;
  position: relative;
  background: rgb(26, 26, 36);
  color: rgb(255, 255, 255);
  font-family: sans-serif;
}

.parallax-scene {
  width: 100%;
  height: 250px;
  position: relative;
  overflow: hidden;
  border-radius: 12px;
  background: linear-gradient(180deg, #0a0a2e 0%, #1a1a4e 50%, #2a1a3e 100%);
  cursor: crosshair;
  /* Touch: a sideways drag moves the layers, a vertical swipe still scrolls the page */
  touch-action: pan-y;
}

.parallax-layer {
  position: absolute;
  inset: -30px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.1s ease-out;
  will-change: transform;
}

.parallax-stars {
  width: 100%;
  height: 100%;
}

.parallax-star {
  position: absolute;
  width: 3px;
  height: 3px;
  background: white;
  border-radius: 50%;
  opacity: 0.6;
}

.parallax-moon {
  width: 60px;
  height: 60px;
  background: radial-gradient(circle at 35% 35%, #fef3c7, #fbbf24);
  border-radius: 50%;
  box-shadow: 0 0 40px rgba(251, 191, 36, 0.4), 0 0 80px rgba(251, 191, 36, 0.2);
}

/* The layers overflow the scene by 30 px on every side: the mountains stand 24 px below
   the bottom edge, the trees 6 px below, so both stay visible when the layers move */
.parallax-mountains {
  position: absolute;
  bottom: 6px;
  width: 120%;
  left: -10%;
}

.parallax-mountain {
  position: absolute;
  bottom: 0;
  width: 0;
  height: 0;
  border-style: solid;
}

.mountain-1 {
  left: 5%;
  border-width: 0 80px 120px 80px;
  border-color: transparent transparent #1e1b4b transparent;
}

.mountain-2 {
  left: 25%;
  border-width: 0 100px 100px 100px;
  border-color: transparent transparent #2e1065 transparent;
}

.mountain-3 {
  left: 55%;
  border-width: 0 90px 130px 90px;
  border-color: transparent transparent #1e1b4b transparent;
}

.mountain-4 {
  left: 75%;
  border-width: 0 70px 90px 70px;
  border-color: transparent transparent #2e1065 transparent;
}

.parallax-trees {
  position: absolute;
  bottom: -40px;
  width: 120%;
  left: -10%;
  display: flex;
  justify-content: space-around;
  align-items: flex-end;
  /* Ground strip under the trees, hidden below the edge at rest: it shows when the trees rise */
  padding-bottom: 64px;
  background: linear-gradient(to top, #022c22 64px, transparent 64px);
}

.parallax-tree {
  width: 0;
  height: 0;
  border-style: solid;
  border-color: transparent transparent #064e3b transparent;
}

.tree-sm {
  border-width: 0 12px 40px 12px;
}

.tree-md {
  border-width: 0 16px 55px 16px;
}

.tree-lg {
  border-width: 0 20px 70px 20px;
}

/* Reduced motion: the landscape stays still in its rest position */
@media (prefers-reduced-motion: reduce) {
  .fx-0021-root .parallax-layer {
    transform: none !important;
    transition: none;
  }
}
JavaScript
(function() {
  // ========== SPATIAL DEPTH ==========
  // ==========================================
  // 1. Mouse Parallax Scene (pointer events: mouse, pen and touch)
  // One instance per .fx-0021-root: several scenes on one page each move on their own.
  // ==========================================
  document.querySelectorAll('.fx-0021-root').forEach(function(root) {
    var scene = root.querySelector('[data-parallax-scene]');
    if (!scene) return;
    var layers = scene.querySelectorAll('.parallax-layer');
    scene.addEventListener('pointermove', function(e) {
      var rect = scene.getBoundingClientRect();
      var centerX = rect.width / 2;
      var centerY = rect.height / 2;
      var mouseX = e.clientX - rect.left - centerX;
      var mouseY = e.clientY - rect.top - centerY;
      layers.forEach(function(layer) {
        var depth = parseFloat(layer.getAttribute('data-depth')) || 0.1;
        var moveX = mouseX * depth * 0.5;
        var moveY = mouseY * depth * 0.5;
        layer.style.transform = 'translate(' + moveX + 'px, ' + moveY + 'px)';
      });
    });
    scene.addEventListener('pointerleave', function() {
      layers.forEach(function(layer) {
        layer.style.transform = 'translate(0, 0)';
      });
    });
  });
})();

Depth Card

A card made of four layers (ring, background, text, icon) that spread apart in 3D and pivot on hover.

CSS 3D Hover

Floating Elements

UI elements floating and oscillating as if weightless with different animation durations.

CSS Animation Float

Perspective Scroll

Four panels that come from far away and rush toward the screen in a loop, in pure CSS (perspective and translateZ).

CSS Perspective 3D

Layered Paper

Stack of paper sheets with realistic shadows and slight rotation, spreading out on hover.

CSS Hover Shadow

Isometric Grid

Interactive isometric grid where blocks rise and fall based on cursor proximity.

JS Mouse Isometric

Depth of Field

Three layers, only one in focus: hover, touch or keyboard moves the focus there, a click keeps it.

CSS Blur Hover

3D Room

Content placed on the floor and walls of a CSS perspective room that turns on drag (mouse or finger) or with the arrow keys and returns to its starting view.

JS 3D Drag
♦
★
♥

Floating Shadows

Three elements resting on their shadows: the mouse acts as the light, and the shadows slide and turn away from it.

JS Mouse Shadow
Effect page →
View source code
HTML
<div class="fx-0029-root">
  <div class="float-shadow-container" data-float-shadow>
    <div class="float-shadow-el">
      <div class="float-shadow-shape fs-shape-1">&#9830;</div>
      <div class="float-shadow-shadow"></div>
    </div>
    <div class="float-shadow-el">
      <div class="float-shadow-shape fs-shape-2">&#9733;</div>
      <div class="float-shadow-shadow"></div>
    </div>
    <div class="float-shadow-el">
      <div class="float-shadow-shape fs-shape-3">&#9829;</div>
      <div class="float-shadow-shadow"></div>
    </div>
  </div>
</div>
CSS
.fx-0029-root,
.fx-0029-root *,
.fx-0029-root *::before,
.fx-0029-root *::after {
  box-sizing: border-box
}

.fx-0029-root {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 250px;
  overflow: hidden;
  position: relative;
  background: rgb(26, 26, 36);
  color: rgb(255, 255, 255);
  font-family: sans-serif;
}

.float-shadow-container {
  width: 100%;
  height: 250px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 30px;
  cursor: crosshair;
  /* Touch: a sideways drag moves the light, a vertical swipe still scrolls the page */
  touch-action: pan-y;
}

.float-shadow-el {
  position: relative;
  transition: transform 0.3s ease;
}

.float-shadow-shape {
  width: 60px;
  height: 60px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  position: relative;
  z-index: 2;
}

.fs-shape-1 {
  background: linear-gradient(135deg, #6366f1, #818cf8);
}

.fs-shape-2 {
  background: linear-gradient(135deg, #ec4899, #f472b6);
  border-radius: 50%;
}

.fs-shape-3 {
  background: linear-gradient(135deg, #10b981, #34d399);
}

.float-shadow-shadow {
  position: absolute;
  bottom: -15px;
  left: 50%;
  transform: translateX(-50%);
  width: 50px;
  height: 10px;
  background: radial-gradient(ellipse, rgba(0, 0, 0, 0.35) 0%, transparent 70%);
  border-radius: 50%;
  transition: all 0.3s ease;
  z-index: 1;
}

/* Reduced motion: the shapes no longer lift; only the shadows follow the light */
@media (prefers-reduced-motion: reduce) {
  .fx-0029-root .float-shadow-shape {
    transform: none !important;
  }
}
JavaScript
(function() {
  // ==========================================
  // 9. Floating Shadows - Dynamic light source (pointer events: mouse, pen and touch)
  // One instance per .fx-0029-root: several groups on one page each follow their own light.
  // ==========================================
  document.querySelectorAll('.fx-0029-root').forEach(function(root) {
    var container = root.querySelector('[data-float-shadow]');
    if (!container) return;
    var elements = container.querySelectorAll('.float-shadow-el');
    container.addEventListener('pointermove', function(e) {
      var rect = container.getBoundingClientRect();
      var mx = e.clientX - rect.left;
      var my = e.clientY - rect.top;
      var centerX = rect.width / 2;
      var centerY = rect.height / 2;
      var lightX = (mx - centerX) / centerX;
      var lightY = (my - centerY) / centerY;

      elements.forEach(function(el) {
        var shape = el.querySelector('.float-shadow-shape');
        var shadow = el.querySelector('.float-shadow-shadow');
        // Move shadow opposite to light direction
        var shadowX = -lightX * 15;
        var shadowY = lightY * 5 + 5;
        var shadowScale = 1 + Math.abs(lightY) * 0.3;
        shadow.style.transform = 'translateX(calc(-50% + ' + shadowX + 'px)) scaleX(' + shadowScale + ')';
        shadow.style.opacity = 0.6 - Math.abs(lightY) * 0.2;
        // Lift shape slightly toward light
        shape.style.transform = 'translate(' + (lightX * 3) + 'px, ' + (-Math.abs(lightY) * 5) + 'px)';
        // Dynamic box shadow on shape
        shape.style.boxShadow = ((-lightX * 8)) + 'px ' + ((-lightY * 8 + 4)) + 'px 20px rgba(0,0,0,0.3)';
      });
    });
    container.addEventListener('pointerleave', function() {
      elements.forEach(function(el) {
        var shape = el.querySelector('.float-shadow-shape');
        var shadow = el.querySelector('.float-shadow-shadow');
        shadow.style.transform = 'translateX(-50%)';
        shadow.style.opacity = '0.35';
        shape.style.transform = 'translate(0, 0)';
        shape.style.boxShadow = '';
      });
    });
  });
})();

Orbit Circle

Elements orbiting around a central point with offset-path: circle(). Varied speeds and directions.

CSS offset-path Orbit
Effect page →
View source code
HTML
<div class="fx-0031-root">
  <div class="mp-orbit-scene">
    <div class="mp-orbit-ring mp-orbit-ring--1"></div>
    <div class="mp-orbit-ring mp-orbit-ring--2"></div>
    <div class="mp-orbit-center"></div>
    <div class="mp-orbit-dot mp-orbit-dot--1"></div>
    <div class="mp-orbit-dot mp-orbit-dot--2"></div>
    <div class="mp-orbit-dot mp-orbit-dot--3"></div>
  </div>
</div>
CSS
.fx-0031-root,
.fx-0031-root *,
.fx-0031-root *::before,
.fx-0031-root *::after {
  box-sizing: border-box
}

.fx-0031-root {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 250px;
  overflow: hidden;
  position: relative;
  background: rgb(26, 26, 36);
  color: rgb(255, 255, 255);
  font-family: sans-serif;
}

.mp-orbit-scene {
  width: 260px;
  height: 260px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mp-orbit-center {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #8b5cf6, #7c3aed);
  box-shadow: 0 0 20px rgba(139, 92, 246, 0.4);
  z-index: 2;
}

.mp-orbit-ring {
  position: absolute;
  border-radius: 50%;
  border: 1px dashed rgba(255, 255, 255, 0.1);
}

.mp-orbit-ring--1 {
  width: 140px;
  height: 140px;
}

.mp-orbit-ring--2 {
  width: 210px;
  height: 210px;
}

.mp-orbit-dot {
  position: absolute;
  border-radius: 50%;
  top: 50%;
  left: 50%;
}

.mp-orbit-dot--1 {
  width: 16px;
  height: 16px;
  background: #ec4899;
  box-shadow: 0 0 10px rgba(236, 72, 153, 0.5);
  offset-path: circle(70px);
  animation: mpOrbit 4s linear infinite;
  margin: -8px 0 0 -8px;
}

.mp-orbit-dot--2 {
  width: 12px;
  height: 12px;
  background: #06b6d4;
  box-shadow: 0 0 10px rgba(6, 182, 212, 0.5);
  offset-path: circle(105px);
  animation: mpOrbit 7s linear infinite reverse;
  margin: -6px 0 0 -6px;
}

.mp-orbit-dot--3 {
  width: 8px;
  height: 8px;
  background: #f59e0b;
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.5);
  offset-path: circle(105px);
  animation: mpOrbit 5s linear infinite;
  margin: -4px 0 0 -4px;
}

@keyframes mpOrbit {
  to {
    offset-distance: 100%;
  }
}

/* Reduced motion: the three dots stop, spread out on their rings (still image). */
@media (prefers-reduced-motion: reduce) {
  .fx-0031-root .mp-orbit-dot { animation: none }
  .fx-0031-root .mp-orbit-dot--1 { offset-distance: 12% }
  .fx-0031-root .mp-orbit-dot--2 { offset-distance: 62% }
  .fx-0031-root .mp-orbit-dot--3 { offset-distance: 30% }
}
JavaScript
/* Pure CSS — no JavaScript required */

SVG Path Follow

Glowing dot following an SVG curve with a ghost trail echoed with a time offset.

CSS SVG Trail

Bezier Curve

Ball following a cubic Bezier curve with visible control points and ground shadow.

CSS Bezier Animation

Infinity Loop

Dot following a lemniscate-shaped (∞) path with a glowing trail halo.

CSS Path Infinity

Spiral Path

Dot traveling along an outward-expanding spiral via a complex SVG path.

CSS Spiral SVG

Bounce Path

Ball following a bounce trajectory with progressively decreasing arcs.

CSS Bounce Physics

Wave Path

Three dots of different sizes and colors following a sine wave with time offsets.

CSS Wave Stagger

Multi Orbit

Miniature solar system with 5 planets on 3 orbits at varied speeds and distances.

CSS Orbit System

Path Drawing

SVG path that draws itself with stroke-dashoffset while a dot follows the same trajectory.

CSS SVG Draw

Rollercoaster

Cart following a rollercoaster track with offset-rotate: auto for natural orientation.

CSS offset-rotate Path

AR/VR & WebXR

Spatial UI Panels

Floating UI panels arranged in an arc in 3D space with parallax effect.

CSS 3D Perspective UI
Effect page →
View source code
HTML
<div class="fx-0041-root">
  <div class="xr-spatial-panels">
    <button type="button" class="xr-panel"><span class="xr-panel-icon" aria-hidden="true">&#128202;</span>Stats</button>
    <button type="button" class="xr-panel"><span class="xr-panel-icon" aria-hidden="true">&#9881;</span>Settings</button>
    <button type="button" class="xr-panel"><span class="xr-panel-icon" aria-hidden="true">&#128100;</span>Profile</button>
  </div>
</div>
CSS
.fx-0041-root,
.fx-0041-root *,
.fx-0041-root *::before,
.fx-0041-root *::after {
  box-sizing: border-box
}

.fx-0041-root {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 250px;
  overflow: hidden;
  position: relative;
  background: rgb(26, 26, 36);
  color: rgb(255, 255, 255);
  font-family: sans-serif;
  perspective: 800px;
}

/* Site design system variables this code depends on (values from css/style.css — adapt freely). */
.fx-0041-root {
  --text-secondary: #a1a1aa;
}

/* The whole arc tilts a little toward the pointer (JS): panels at different depths shift apart = parallax. */
.xr-spatial-panels {
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.4s ease-out;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
}

.xr-panel {
  width: 80px;
  height: 100px;
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: 12px;
  backdrop-filter: blur(10px);
  padding: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  color: var(--text-secondary);
  text-align: center;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.5s cubic-bezier(0.23, 1, 0.32, 1);
}

.xr-panel:nth-child(1) {
  transform: rotateY(-25deg) translateZ(30px);
}

.xr-panel:nth-child(2) {
  transform: rotateY(0deg) translateZ(50px);
}

.xr-panel:nth-child(3) {
  transform: rotateY(25deg) translateZ(30px);
}

.xr-panel:hover,
.xr-panel:focus-visible {
  transform: rotateY(0deg) translateZ(70px) scale(1.1);
}

.xr-panel-icon {
  font-size: 1.5rem;
  margin-bottom: 6px;
}

.xr-panel:focus-visible {
  outline: 2px solid #a5b4fc;
  outline-offset: 3px;
}

/* Reduced motion: no tilt, and the chosen panel stays in place; it lights up instead. */
@media (prefers-reduced-motion: reduce) {
  .fx-0041-root .xr-spatial-panels { transform: none; transition: none; }
  .fx-0041-root .xr-panel { transition: background-color 0.2s, border-color 0.2s, color 0.2s; }
  .fx-0041-root .xr-panel:nth-child(1):hover,
  .fx-0041-root .xr-panel:nth-child(1):focus-visible { transform: rotateY(-25deg) translateZ(30px); }
  .fx-0041-root .xr-panel:nth-child(2):hover,
  .fx-0041-root .xr-panel:nth-child(2):focus-visible { transform: rotateY(0deg) translateZ(50px); }
  .fx-0041-root .xr-panel:nth-child(3):hover,
  .fx-0041-root .xr-panel:nth-child(3):focus-visible { transform: rotateY(25deg) translateZ(30px); }
  .fx-0041-root .xr-panel:hover,
  .fx-0041-root .xr-panel:focus-visible {
    background: rgba(99, 102, 241, 0.35);
    border-color: rgba(165, 180, 252, 0.8);
    color: #fff;
  }
}
JavaScript
(function() {
  // ============================================
  // SPATIAL UI PANELS - parallax: the arc turns slightly under the pointer
  // ============================================
  var reduce = window.matchMedia('(prefers-reduced-motion: reduce)');

  document.querySelectorAll('.fx-0041-root').forEach(function(root) {
    var arc = root.querySelector('.xr-spatial-panels');
    if (!arc) return;

    // The pointer's side moves back (up to 8 deg left and right, 6 deg top and bottom); forward panels (50 to 70 px) move more than the ones behind.
    function tilt(e) {
      if (reduce.matches) return;
      var r = root.getBoundingClientRect();
      var x = (e.clientX - r.left) / r.width - 0.5;
      var y = (e.clientY - r.top) / r.height - 0.5;
      arc.style.transform = 'rotateX(' + (-y * 12).toFixed(2) + 'deg) rotateY(' + (x * 16).toFixed(2) + 'deg)';
    }
    root.addEventListener('pointermove', tilt);
    root.addEventListener('pointerdown', tilt); // with a finger: the arc turns toward the touched point and stays there
    root.addEventListener('pointerleave', function(e) {
      if (e.pointerType !== 'touch') arc.style.transform = '';
    });
  });
})();

360 Viewer

A horizontal panorama to drag (mouse, finger, arrow keys) that loops endlessly: the full turn for a 360° photo.

JS Drag Panorama

AR Object Placer

An object floats above a perspective grid; a click on a cell sets it down there (illustration, no camera).

CSS AR Placement

Holographic Display

Holographic display with scanline, prismatic reflections and light pulsation.

CSS Hologram Animation
Effect page →
View source code
HTML
<div class="fx-0045-root">
  <div class="xr-holo-display">
    <div class="xr-holo-box">
      <div class="xr-holo-scanline"></div>
      <div class="xr-holo-prism"></div>
    </div>
  </div>
</div>
CSS
.fx-0045-root,
.fx-0045-root *,
.fx-0045-root *::before,
.fx-0045-root *::after {
  box-sizing: border-box
}

.fx-0045-root {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 250px;
  overflow: hidden;
  position: relative;
  background: rgb(26, 26, 36);
  color: rgb(255, 255, 255);
  font-family: sans-serif;
}

.xr-holo-display {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.xr-holo-box {
  width: 120px;
  height: 120px;
  position: relative;
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: 8px;
  background: rgba(99, 102, 241, 0.05);
  /* Keeps the rotating prism reflection inside the frame */
  overflow: hidden;
  animation: xrHoloPulse 3s ease-in-out infinite;
}

.xr-holo-scanline {
  position: absolute;
  left: 0;
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(99, 102, 241, 0.6), transparent);
  animation: xrScanline 2s linear infinite;
}

.xr-holo-prism {
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent 30%, rgba(99, 102, 241, 0.1) 45%, rgba(168, 85, 247, 0.1) 55%, transparent 70%);
  animation: xrPrism 4s linear infinite;
}

@keyframes xrScanline {
  from {
    top: 0;
  }

  to {
    top: 100%;
  }
}

@keyframes xrHoloPulse {

  0%,
  100% {
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.2);
  }

  50% {
    box-shadow: 0 0 40px rgba(99, 102, 241, 0.4), inset 0 0 20px rgba(99, 102, 241, 0.1);
  }
}

@keyframes xrPrism {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

/* Reduced motion: still hologram, scanline at mid-height, steady glow */
@media (prefers-reduced-motion: reduce) {
  .fx-0045-root .xr-holo-box {
    animation: none;
    box-shadow: 0 0 30px rgba(99, 102, 241, 0.3), inset 0 0 10px rgba(99, 102, 241, 0.05);
  }

  .fx-0045-root .xr-holo-scanline {
    animation: none;
    top: 50%;
  }

  .fx-0045-root .xr-holo-prism {
    animation: none;
  }
}
JavaScript
/* Pure CSS — no JavaScript required */

Spatial Audio Dir

Visual sound-direction indicator (plays no sound): concentric waves and a source circling around.

CSS Audio Spatial

Portal Effect

Portal to another dimension: rotating ring and pulsing light core, scattered with particles.

CSS JS Portal

Hand Tracking UI

Gesture-reactive interface simulated with a custom cursor (mouse, finger or keyboard, no camera).

JS Gestures UI
Effect page →
View source code
HTML
<div class="fx-0048-root">
  <div class="xr-hand-tracking">
    <button type="button" class="xr-hand-btn" aria-pressed="false">Select</button>
    <button type="button" class="xr-hand-btn" aria-pressed="false">Grab</button>
    <button type="button" class="xr-hand-btn" aria-pressed="false">Point</button>
    <div class="xr-hand-cursor" aria-hidden="true"></div>
  </div>
</div>
CSS
.fx-0048-root,
.fx-0048-root *,
.fx-0048-root *::before,
.fx-0048-root *::after {
  box-sizing: border-box
}

.fx-0048-root {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 250px;
  overflow: hidden;
  position: relative;
  background: rgb(26, 26, 36);
  color: rgb(255, 255, 255);
  font-family: sans-serif;
}

/* Site design system variables this code depends on (values from css/style.css — adapt freely). */
.fx-0048-root {
  --text-secondary: #a1a1aa;
}

.xr-hand-tracking {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  /* Touch: a sideways drag moves the ring, a vertical swipe still scrolls the page */
  touch-action: pan-y;
}

.xr-hand-cursor {
  width: 24px;
  height: 24px;
  border: 2px solid #6366f1;
  border-radius: 50%;
  position: absolute;
  /* Starting position: below the row of buttons, not covering one */
  left: calc(50% - 12px);
  top: calc(50% + 34px);
  pointer-events: none;
  transition: transform 0.1s ease;
}

.xr-hand-cursor::after {
  content: '';
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  background: rgba(99, 102, 241, 0.3);
}

.xr-hand-btn {
  font-family: inherit;
  padding: 10px 20px;
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.3s ease;
  margin: 0 8px;
}

.xr-hand-btn:hover {
  background: rgba(99, 102, 241, 0.3);
  transform: scale(1.05);
}

.xr-hand-btn.active {
  background: rgba(99, 102, 241, 0.4);
  border-color: #6366f1;
}

.xr-hand-btn:focus-visible {
  outline: 2px solid #a5b4fc;
  outline-offset: 2px;
}

/* Reduced motion: the ring still follows the pointer, but it no longer squeezes and the buttons no longer grow */
@media (prefers-reduced-motion: reduce) {
  .fx-0048-root .xr-hand-cursor {
    transform: none !important;
    transition: none;
  }

  .fx-0048-root .xr-hand-btn {
    transition: none;
  }

  .fx-0048-root .xr-hand-btn:hover {
    transform: none;
  }
}
JavaScript
(function() {
  // Hand Tracking UI — the ring follows the mouse, the finger or the keyboard focus (fx-0048)
  // One instance per .fx-0048-root: several copies on one page each have their own ring.
  document.querySelectorAll('.fx-0048-root').forEach(function(root) {
    var container = root.querySelector('.xr-hand-tracking');
    var cursor = root.querySelector('.xr-hand-cursor');
    if (!container || !cursor) return;
    var buttons = container.querySelectorAll('.xr-hand-btn');

    // x, y: coordinates in the window (pointer, or center of the focused button)
    function moveTo(x, y) {
      var rect = container.getBoundingClientRect();
      cursor.style.left = (x - rect.left - 12) + 'px';
      cursor.style.top = (y - rect.top - 12) + 'px';
    }

    function follow(e) {
      moveTo(e.clientX, e.clientY);
    }

    container.addEventListener('pointermove', follow);
    container.addEventListener('pointerdown', follow);

    // Keyboard: the ring jumps onto the button that gets the focus (Tab), Enter or Space presses it
    container.addEventListener('focusin', function(e) {
      var btn = e.target.closest('.xr-hand-btn');
      if (!btn || !btn.matches(':focus-visible')) return;
      var r = btn.getBoundingClientRect();
      moveTo(r.left + r.width / 2, r.top + r.height / 2);
    });

    buttons.forEach(function(btn) {
      btn.addEventListener('click', function() {
        buttons.forEach(function(b) {
          b.classList.remove('active');
          b.setAttribute('aria-pressed', 'false');
        });
        btn.classList.add('active');
        btn.setAttribute('aria-pressed', 'true');
        cursor.style.transform = 'scale(0.8)';
        setTimeout(function() {
          cursor.style.transform = 'scale(1)';
        }, 200);
      });
    });
  });
})();

Immersive Depth Scroll

Z-depth layers that react to mouse movement for an immersive parallax effect.

CSS 3D Parallax Depth

XR Environment

A virtual space scene: a twinkling starry sky, a perspective grid floor and two floating shapes (CSS, no headset, no WebXR).

CSS JS Environment

3D Product Showcase

Real interactive 3D model (.glb): 360° drag rotation, auto-rotate, realistic shadows and augmented reality view on mobile. The premium packshot that sells.

💡 Ideal for: product page, limited edition, configurator, e-commerce hero, premium listing, Black Friday.

model-viewer .glb / AR Product Premium

Architectural Mandala

An endless city built in concentric rings: apartment blocks with rows of windows, arcaded arenas, colonnades, amphitheatre tiers, belvedere towers and staircases linking the levels slowly turn around a glowing core, with real shadows and a mist that swallows the floors below. At night, a few windows light up. Drag to spin it (it keeps its momentum), zoom with the wheel or a pinch, pan with two fingers; everything works from the keyboard too. Three palettes, and a button that rebuilds a new city block by block. Hand-written WebGL2 engine, no library; resolution adapts to the device, and without WebGL a CSS mandala takes over.

💡 Perfect for: hero of an architecture or design studio, exhibition or biennale page, product launch, “about” page background, creative portfolio.

WebGL2 Interactive 3D Generative Architecture Premium

Frequently Asked Questions

How to create a flip card in CSS? +

Use a container with perspective:1000px, an inner card with transform-style:preserve-3d and transition. The back face has backface-visibility:hidden and rotateY(180deg). On hover, the card rotates 180deg.

What is the difference between perspective and 3D transform? +

perspective defines the distance between the viewer and the element -- it goes on the PARENT. 3D transforms (rotateX, rotateY, translateZ) deform the element itself. The smaller the perspective, the more pronounced the effect.

How to create a 3D carousel in CSS? +

Place items in a circle with rotateY and translateZ in a container with transform-style:preserve-3d. Each item has rotateY(i * 360/n deg) translateZ(radius). Animate the container rotation to scroll through.

Is WebGL necessary for web 3D effects? +

Not for most effects: CSS perspective + transforms are sufficient for cards, carousels and parallax. WebGL (via Three.js) is only necessary for complex 3D scenes: models, textures, lights, physics.

Are CSS 3D effects performant? +

Yes. 3D transforms are processed by the GPU. Avoid combining transform with filter on the same element. Limit the number of elements with preserve-3d as each 3D layer consumes GPU memory.

Similar Categories