Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / CSS

CSS property `perspective-origin`

`perspective-origin` sets the viewing point toward which descendants’ 3D projections converge; the initial `50% 50%` places it at the center of the reference box.

Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required

Syntax

<position>

perspective-origin sets the viewing point toward which descendants’ 3D projections converge; the initial 50% 50% places it at the center of the reference box.

The example compares identical scenes: the centered point enlarges a card symmetrically, while 0 0 moves the perspective reference point to the container’s top-left; the measured enlarged rectangle therefore starts 100 pixels right and 60 pixels down from the scene.

Grammar: <position>.

The horizontal percentage resolves against width and the vertical one against height. The property has an effect only with a non-none perspective on the same element and does not replace transform-origin, which sets the transform pivot of an element itself.

Examples

<!doctype html><meta charset="utf-8"><style>html,body{margin:0}.scene{position:absolute;top:0;width:200px;height:120px;perspective:200px}.card{position:absolute;left:50px;top:30px;width:100px;height:60px;transform:translateZ(100px)}</style><div id="centered" class="scene" style="left:0"><i class="card"></i></div><div id="corner" class="scene" style="left:300px;perspective-origin:0 0"><i class="card"></i></div><pre id="result"></pre><script>const relative=(scene)=>{const outer=scene.getBoundingClientRect(),inner=scene.firstElementChild.getBoundingClientRect();return [Math.round(inner.left-outer.left),Math.round(inner.top-outer.top),Math.round(inner.width),Math.round(inner.height)]},a=relative(centered),b=relative(corner),centerValue=getComputedStyle(centered).perspectiveOrigin,cornerValue=getComputedStyle(corner).perspectiveOrigin;if(a.join(',')!=='0,0,200,120'||b.join(',')!=='100,60,200,120'||centerValue!=='100px 60px'||cornerValue!=='0px 0px')throw new Error('perspective-origin geometry mismatch '+[a,b,centerValue,cornerValue]);result.textContent='center='+a.join(',')+'; corner='+b.join(',')+'; computed='+centerValue+'/'+cornerValue;</script>

Result

center=0,0,200,120; corner=100,60,200,120; computed=100px 60px/0px 0px

The example compares identical scenes: the centered point enlarges a card symmetrically, while `0 0` moves the perspective reference point to the container’s top-left; the measured enlarged rectangle therefore starts 100 pixels right and 60 pixels down from the scene.

Sources