perspective-origin

Term side of the Card.
Topic: Transformations
Unit title: perspective-origin
Categories: Property
Explanation side of the Card

Explanation: The property that defines the point from which the viewer is looking at the element in a 3D space when the `perspective` property is applied. It controls the vanishing point of the perspective effect, determining how the 3D transformation appears.

Browser compatibility:
  • The chrome browser supports this feature starting from version 36.
  • The edge browser supports this feature starting from version 12.
  • The firefox browser supports this feature starting from version 16.
  • The safari browser supports this feature starting from version 9.
Availability: 

Example

Wrongcss
.cube {
  perspective-origin: top left;
  transform: rotateX(20deg);
}
Rightcss
.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-origin on the transformed child, where it does nothing.

Key points

  • perspective-origin is set on the same element as perspective.
  • That element has a perspective value, 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.

Analytics cookiesWe'd like to use analytics cookies to see which pages are useful. They're set only if you accept. Privacy Policy