Thanks to visit codestin.com
Credit goes to www.cssportal.com

CSS Portal

CSS transform-style Property

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!

Description

The transform-style property controls whether an element’s transformed children participate in a shared three-dimensional rendering context or are visually flattened into the plane of the element. In practical terms, it determines how nested transforms combine: when children retain their own 3D positions relative to one another, depth and rotation effects applied on descendants can be seen together as part of a coherent 3D scene. When children are flattened, their transforms are collapsed into the parent’s plane, so nested depth and overlapping order no longer produce a continuous 3D composition.

This behavior becomes important whenever you apply a transform to elements that contain other transformed descendants. If the children are preserved in three dimensions, their individual transforms accumulate and are projected relative to any perspective or viewing transform higher in the tree. If they are flattened, those descendant transforms are effectively combined into a single two-dimensional result before any ancestor-level projection takes place. That distinction changes how rotations, translations along the Z axis, and 3D stacking appear to the user.

The interaction with ancestor-level projection is another key consideration. When an ancestor provides a perspective, whether descendants are preserved as 3D objects or flattened affects whether that perspective is applied to each child’s 3D position or only to the parent’s flattened composite. Designers working with layered, nested 3D effects (for example, multi-part 3D widgets or card stacks with independent rotations) need the preserved 3D behavior to maintain believable depth relationships; simple two-dimensional effects and single-plane transformations are often simpler and cheaper to render when flattening is used.

Finally, consider performance and compositing consequences. Preserving nested 3D contexts often forces browsers to create additional compositing layers and can trigger GPU acceleration, which improves visual smoothness for complex animations but may increase memory and rendering overhead. The property itself is only about visual rendering — it does not change document layout or flow — so its primary effects are visual composition, the way transforms of nested elements combine, and how those results interact with perspective and other rendering-related properties.

Definition

Initial value
flat
Applies to
Transformable elements
Inherited
No
Computed value
Same as specified value
Animatable
No
JavaScript syntax
object.style.transformStyle

Interactive Demo

Parent

rotate3d(1, 1, 1, 45deg)

Syntax

transform-style: flat | preserve-3d

Values

  • flatChild elements will not preserve their 3D position before applying a transform.
  • preserve-3dChild elements will preserve their 3D position before applying a transform.

Example

<div class='container'>
<div class='wrap'>
<div class='box preserve'>
<div class='surface base'>Base</div>
<div class='surface pop'>Pop-out (preserve-3d)</div>
</div>
<div class='label'>transform-style: preserve-3d</div>
</div>

<div class='wrap'>
<div class='box flat'>
<div class='surface base'>Base</div>
<div class='surface pop'>Pop-out (flat)</div>
</div>
<div class='label'>transform-style: flat</div>
</div>
</div>
/* Demo showing transform-style: preserve-3d vs flat */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, Roboto, Arial, sans-serif;
  background: linear-gradient(180deg,#eef6ff,#f7fbff);
  color: #213;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
}

.container {
  display: flex;
  gap: 48px;
  align-items: center;
}

.wrap {
  perspective: 900px; /* Provide perspective so 3D effect is visible */
  text-align: center;
}

.box {
  width: 240px;
  height: 140px;
  position: relative;
  margin: 0 auto;
  transform: rotateX(18deg) rotateY(-22deg);
  transition: transform .45s ease;
}

.box.preserve {
  transform-style: preserve-3d; /* children keep their 3D transforms */
}

.box.flat {
  transform-style: flat; /* children are flattened into the box's plane */
}

.surface {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  color: #fff;
  font-weight: 600;
  box-shadow: 0 10px 30px rgba(16,24,40,0.12);
}

.surface.base {
  background: linear-gradient(135deg,#6c8cff,#8ae1ff);
}

.surface.pop {
  background: linear-gradient(135deg,#ff9a9e,#fecf8a);
  transform: translateZ(40px); /* this Z translation is preserved only when parent has preserve-3d */
}

.label {
  margin-top: 12px;
  font-size: 14px;
  color: #273447;
}

@media (max-width: 640px) {
  .container {
    flex-direction: column;
    gap: 24px;
  }
}

Browser Support

The following information will show you the current browser support for the CSS transform-style property. Hover over a browser icon to see the version that first introduced support for this CSS property.

This property is supported by all modern browsers.
Desktop
Chrome
Edge
Firefox
Opera
Safari
Tablets & Mobile
Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-

Last updated by CSSPortal on: 1st January 2026

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!