CSS propertyTransforms

transform-style

Decides whether an element’s children live in a shared 3D space or are flattened.

Initial value
flat
Inherited
No
Animatable
no
Applies to
transformable elements
JavaScript
element.style.transformStyle = "preserve-3d"
On this page

Example

#
CSS
.cube {
  transform-style: preserve-3d;
  animation: spin 6s linear infinite;
}

@keyframes spin {
  to { transform: rotateX(360deg) rotateY(360deg); }
}
Preview

Definition and usage

#

The transform-style property is set on the parent of elements transformed in 3D. By default (flat), children are flattened onto the parent’s plane, so nested 3D rotations do not form a real solid.

The preserve-3d value keeps the third dimension: children can be in front of and behind each other, and rotating the parent rotates the whole scene. This lets you build a cube from six faces or a flip card.

Some properties, such as overflow: hidden or filter, force flattening and disable the preserve-3d effect.

Syntax

#
Syntax
transform-style: flat | preserve-3d;

Values

#
  • flat

    The inner tile is flattened onto the parent’s plane.
  • preserve-3d

    The inner tile floats above the parent in 3D space.

Values in practice

#

flat

The inner tile is flattened onto the parent’s plane.
.demo { transform-style: flat; }

preserve-3d

The inner tile floats above the parent in 3D space.
.demo { transform-style: preserve-3d; }

Browser support

#

Widely available

Works in all modern browsers, phones included. You can use it without worry.

  • Chrome
  • Edge
  • Firefox
  • Safari

Good practices

#
  • If a 3D solid “flattens”, look for overflow: hidden, filter, or opacity below 1 on the parent.
  • Respect the reduced-motion setting: under prefers-reduced-motion: reduce, stop rotating scenes.

Related entries

#

Practise it in lessons

#

Spotted a mistake or missing an example? Write to us.