perspective-origin
Example
.cube {
perspective-origin: top left;
transform: rotateX(20deg);
}.scene {
perspective: 600px;
perspective-origin: top left;
}
.cube {
transform: rotateX(20deg);
}The vanishing point belongs to the parent with perspective, not to the element being rotated.
Common mistakes
- Setting
perspective-originon the transformed child, where it does nothing.
Key points
perspective-originis set on the same element asperspective.- That element has a
perspectivevalue, or the origin has no effect.
Interview questions
What is the default perspective-origin?
'50% 50%', the center of the element.
What is the difference between perspective-origin and transform-origin?
perspective-origin sets where the viewer looks from; transform-origin sets the point an element rotates or scales around.