CKTIS / CSS
CSS property `perspective`
`perspective` sets, on a container, the distance from the z=0 plane to the viewer and projects three-dimensional transforms of its children; a smaller positive length produces stronger foreshortening.
Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required
Syntax
none | <length [0,∞]>perspective sets, on a container, the distance from the z=0 plane to the viewer and projects three-dimensional transforms of its children; a smaller positive length produces stronger foreshortening.
The example compares a child using translateZ(100px) in a scene set to 200px with the same scene set to none: the first card becomes twice as wide while the second keeps its unprojected width.
Grammar: none | <length [0,∞]>.
Zero is valid, but lengths below 1px are clamped to 1 px for rendering without changing the computed value. none disables the perspective matrix; a non-none value creates a stacking context and a containing block for descendants.
Examples
<!doctype html><meta charset="utf-8"><style>html,body{margin:0}.scene{position:absolute;top:0;width:200px;height:200px}.card{position:absolute;left:50px;top:50px;width:100px;height:100px;transform:translateZ(100px)}</style><div id="near" class="scene" style="left:0;perspective:200px"><i class="card"></i></div><div id="flat" class="scene" style="left:300px;perspective:none"><i class="card"></i></div><div id="zero" style="perspective:0"></div><pre id="result"></pre><script>const nearWidth=Math.round(near.firstElementChild.getBoundingClientRect().width),flatWidth=Math.round(flat.firstElementChild.getBoundingClientRect().width),nearValue=getComputedStyle(near).perspective,flatValue=getComputedStyle(flat).perspective,zeroValue=getComputedStyle(zero).perspective,negative=CSS.supports('perspective','-1px');if(nearWidth!==200||flatWidth!==100||nearValue!=='200px'||flatValue!=='none'||zeroValue!=='0px'||negative)throw new Error('perspective geometry mismatch');result.textContent='width='+nearWidth+'/'+flatWidth+'; computed='+nearValue+'/'+flatValue+'; zero='+zeroValue+'; negative='+negative;</script>Result
width=200/100; computed=200px/none; zero=0px; negative=false
The example compares a child using `translateZ(100px)` in a scene set to `200px` with the same scene set to `none`: the first card becomes twice as wide while the second keeps its unprojected width.