Skip to content
Tutorials Center
My learning

Topics

CSS Reference ยท Transforms, Transitions and Animations

The transform-style property

Reference for the CSS transform-style property: keep child elements in a shared 3D space with preserve-3d, and learn which properties flatten it again.

The transform-style property decides whether the children of a transformed element live in the same 3D space as their parent or are flattened onto the parent's plane. With flat, the default, children are drawn as a picture on the parent's surface, so their own 3D transforms look flat. With preserve-3d, they stay separate 3D objects that can sit in front of and behind each other.

You need it whenever you build a cube, a flipping card or any scene where several 3D-transformed elements are nested.

CSS
.scene {
  transform-style: preserve-3d;
}

Try it

Flat versus preserve-3d

In the flat version the two layers are squashed onto one plane, so their depth difference has no effect. With preserve-3d the layers keep their gap in depth and the rotation reveals it.

Syntax

CSS
transform-style: flat | preserve-3d;
  • Initial value: flat
  • Applies to: transformable elements
  • Inherited: no
  • Animatable: no (discrete)
  • Computed value: as specified, but forced to flat by some other properties (see below)

Values

Value Description
flat Children are flattened into the plane of the element.
preserve-3d Children are positioned in the element's 3D space and can intersect or overlap in depth.

Usage notes

  • Set it on the parent, not the child. Every element between the scene and the 3D-transformed layers needs preserve-3d, or the chain breaks.
  • These properties force flat on the element (as used value): overflow other than visible, opacity less than 1, filter, clip-path, mask, isolation: isolate and mix-blend-mode other than normal. If a 3D scene collapses, look for one of these.
  • perspective is separate. Put perspective on the container above the scene to get depth; transform-style only keeps the nesting.
  • Backfaces. Use backface-visibility: hidden on card faces so you see only the side facing you.
  • Cost. Large 3D scenes with many layers can be heavy on low-end devices.

Browser support

Supported in every current browser.