Perspective - Property CSS
Summary of characteristics of the perspective property
nonenoneComputed value: during an animation, the perspective property gradually changes from one value to another.Single: single value (no order).Syntax diagram of perspective.
perspective property.The links in the diagram provide more details about the values.
In the diagram, the bold terms are the predefined words of CSS, the other terms are described below::
lengthis a positive or zero numeric value, followed by one of CSS dimension units.
Description of the perspective property.
The property perspective sets a perspective effect on an element that has undergone a 3D transformation.
Refer to the page on transform for an overview of CSS transformations.
Untransformed element: it is in the 2D plane.
This element has undergone a rotation. Without the effect of perspective, it simply appears compressed.
This element underwent the same rotation, but with a perspective effect.
The property applies to the container. The perspective effect is calculated by considering that the observer is at the center of the container element.
See the perspective-origin property to change the position of the observer.

Values below 1 pixel are rounded up to 1 pixel. In any case, it is rare to go down to such low values because the rendering then looks strange. Generally, we stick to minimum values of 50 pixels.
perspective has no effect on elements that have not undergone transformation, or those that have undergone a transformation that leaves them
in the 2D plane. The effect of perspective is visible on the following transformations:
- Rotations around the X axis (horizontal) or around the Y axis (vertical).
- Translation along the Z axis.
- All combinations involving at least one of the transformation above.
Warning, unlike the function perspective(), the property perspective applies its effect on child elements. Therefore,
the property must be applied to the container. The result, however, is noticeably different.
Property
perspective applied to the parent.Function
perspective() applied to the child.Values for perspective.
- perspective: none;
No perspective effect is applied.
😸 😹 😻 - perspective: 200px;
This value defines the distance between the observer and the element. The perspective effect is greater the closer the observer and the element are.
The value is a strictly positive number, followed by one of CSS dimension units. Percentages are not allowed.
😸 😹 😻perspective:100px;😸 😹 😻perspective:200px; - perspective: initial; (
none) perspective: inherit; perspective: revert; perspective: revertLayer; perspective: unset;Common values are presented on these pages:
initial,inherit,revert,revert-layer,unset.
Animation of the perspective property.
The animation of perspective can produce surprising results. For example, in this example it seems that the speed of the animation is not constant at all.
Yet it is indeed a linear animation, but the perspective calculation is much more sensitive for small values (where the perspective effect is most pronounced).
The example consists of a parent element, on which the perspective is applied (with animation), and a child element on which the transformation has been applied. Here, it is a rotation along the Y axis (vertical).
Simulator.
The simulator below will allow you to understand the effect of the perspective property: the two inner frames have already received the styles
to rotate them along the X or Y axis. Enter a size between 50px and 700px and observe the result. Below 50 pixels, the distortion is really too strong
and makes the text unreadable. Above 700px, the perspective variations are too subtle.
The observer is supposed to be located in the middle of the parent element. Its position is represented by the drawing of an eye.
See the property perspective-origin to change this location.

For fun, you can also watch all this in animation
Browsers compatibility with perspective.
the backface-visibility property.perspective to define the height of the viewpoint (3D transformations).Notes:
(1) Internet Explorer does not support transform-style:preserve-3d, thus limiting the nesting of animations.
(2) In IOS 13, the perspective property does not work correctly.
transformations
perspectiveproperty
Browsers on computers :
Mobile browsers :
Outdated or marginal browsers :

Internet Explorer

KaiOS Browser

Opéra Mobile

Opéra

Firefox pour Androïd

Samsung Internet

Chrome

Edge

Firefox

Androïd Brower

Chrome pour Androïd

Baidu Browser

QQ Browser

Safari

Safari sur IOS

UC Browser pour Androïd

Opéra mini
Historic of the perspective property.
-
CSS Transforms Module Level 2
In addition to the 2D transformations already presented in level 1 of the specification, this module deals with 3D transformations. It introduces new properties to manage the viewpoint height and the rendering of 3D effects.
This module also introduces the individual properties of rotation, translation, and zoom effect.Regardingperspective. Introduction of 3D transformations and theperspectiveproperty in the transformation specification.March 03, 2020Working Draft.
See also, regarding the transformations.
The W3C organizes CSS specifications into modules. The CSS Transforms Module gathers all the definitions concerning CSS transformations:
Properties:

Functions:





