transform-style
Example
.card {
transform-style: preserve-3d;
overflow: hidden;
}.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: hiddenon the card flattens its children.
Key points
transform-style: preserve-3dis set on the parent whose children are placed in 3D.- That parent has no
overflow: hidden,filteroropacitybelow 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.