transform-style

Term side of the Card.
Topic: Transformations
Unit title: transform-style
Categories: Property
Explanation side of the Card

Explanation: The property that specifies how nested elements are rendered in 3D space. It can be set to 'flat' to flatten child elements or 'preserve-3d' to maintain their 3D positioning, affecting how transformations are applied to nested elements.

Browser compatibility:
  • The chrome browser supports this feature starting from version 36.
  • The edge browser supports this feature starting from version 12.
  • The firefox browser supports this feature starting from version 16.
  • The safari browser supports this feature starting from version 9.
Availability: 

Example

Wrongcss
.card {
  transform-style: preserve-3d;
  overflow: hidden;
}
Rightcss
.card {
  transform-style: preserve-3d;
}
.card-face {
  overflow: hidden;
}

overflow: hidden on the 3D parent forces it flat, so clipping moves to the faces instead.

Common mistakes

  • A card flip looks flat because overflow: hidden on the card flattens its children.

Key points

  • transform-style: preserve-3d is set on the parent whose children are placed in 3D.
  • That parent has no overflow: hidden, filter or opacity below 1, since they flatten the 3D context.
  • An ancestor sets perspective, so the depth is visible.

Interview questions

Is transform-style inherited?

No. Each nesting level that must stay in 3D needs its own preserve-3d.

What is the default value of transform-style?

'flat', so children are drawn into the plane of their parent.

Analytics cookiesWe'd like to use analytics cookies to see which pages are useful. They're set only if you accept. Privacy Policy