CSS Reference ยท Transforms, Transitions and Animations
The perspective-origin property
Reference for the CSS perspective-origin property: move the vanishing point of a 3D scene, with syntax, values, live examples and browser support.
The perspective-origin property sets the vanishing point of a 3D scene: the spot that the viewer is looking straight at. It only matters on an element that also has the perspective property, and it affects how that element's children look when they are transformed in 3D.
By default the vanishing point is the center of the element (50% 50%). Moving it left, right, up or down changes the angle you appear to view the scene from, without moving any of the content.
.stage { perspective: 400px; perspective-origin: 20% 50%; }
Try it
All three cards have the same rotateY(50deg) transform. Only the vanishing point of the surrounding stage differs, so the same rotation looks different in each box.
Syntax
perspective-origin: <position> /* examples */ perspective-origin: center; perspective-origin: left top; perspective-origin: 25% 75%; perspective-origin: 10rem 40px; perspective-origin: right 20px bottom 10px;
- Initial value:
50% 50% - Applies to: transformable elements
- Inherited: no
- Percentages: refer to the size of the element's reference box (its border box by default)
- Animatable: yes, as a length or percentage
- Computed value: the horizontal and vertical offsets, with lengths made absolute
Values
| Value | Description |
|---|---|
left, center, right |
Keyword for the horizontal position. |
top, center, bottom |
Keyword for the vertical position. |
<length> |
An offset from the top-left corner, such as 40px or 10rem. Negative values are allowed. |
<percentage> |
A share of the box's width (horizontal) or height (vertical). |
| Edge offsets | The four-value form such as right 20px bottom 10px measures offsets from the named edges. |
With one value, the other axis defaults to center. With two values, the first is horizontal and the second vertical, unless you use keywords that name the axis (top left also works).
Usage notes
- It needs
perspective.perspective-originis set on the same element asperspective, the parent of the transformed children. On its own it does nothing. - Not the same as
transform-origin.transform-originis the pivot point of one element's own transform.perspective-originis where the viewer's eye sits for all the children. Theperspective()transform function also usestransform-origin, notperspective-origin. - Only the parent matters. Children cannot override the vanishing point; it belongs to the element that creates the perspective.
- Preserving 3D. If the children contain further 3D-transformed elements, set
transform-style: preserve-3don the children so the deeper levels share the same scene. - Use it for parallax and tilt effects. Animating
perspective-originfrom a pointer position makes a scene seem to follow the mouse. Keep the motion small and respectprefers-reduced-motion. - Keep it subtle. Large offsets on a short
perspectivedistort objects strongly. If a scene looks stretched, increase theperspectivevalue.
Browser support
Supported in all current browsers; older Safari versions needed the -webkit- prefix, which modern code no longer needs.
Related
perspectiveโ the depth of the 3D scenetransform-styleโ keeps nested elements in 3Dtransform-originโ the pivot of a single transformbackface-visibilityโ hides the back of a rotated element- Lessons: 3D Transforms, Transforms