Perspective() - CSS Function
Summary of characteristics of the perspective() function
Description of the perspective() function.
The function perspective() sets the distance between the observer and the element along the Z-axis.
As long as the transformations happen in the plane of the screen (along the X-axis or Y-axis), perspective has no effect.
But transformations that move the element along the Z-axis will be affected by perspective: if the element gets closer, it will appear bigger;
if it moves away, it will shrink.
Example: the three blocks below have identical dimensions. The first one is in the plane of the screen: its dimensions are unchanged; the second one has
been moved back, using a negative value for translatez(); and the third one has been moved forward.
You'll notice that they all really do have the same dimensions. Their size difference is only due to their distance from the viewer.
translatez(0)translatez(-100px)translatez(100px)There is also a property perspective that has a similar role, but with one difference: the property applies to the parent of the transformed element,
whereas the function applies to the element itself, via the property transform.
The perspective() value can be used with the following properties:
transform: Applies one or more geometric transformations (rotations, enlargements, etc.).
Syntaxes of the perspective() function.
- transform: perspective(200px); h
his a positive number followed by a unit of absolute dimension (See CSS dimension units).
It defines the observer's height, in other words the distance between the observer and the next element along the Z axis. The smaller this number, the stronger the perspective effect.
Simulator.
The perspective effect is visible when a transformation moves an element out of the screen plane.
The third block has been rotated around the Z axis: it stays in the screen plane, so the perspective() function has no effect on it.
Browsers compatibility with perspective() function.
All the common browsers handle 3D transformations correctly, as well as the perspective() function, which is essential for 3D rendering.
the backface-visibility property.perspective() which allows for better visualization of the effects of a 3D transformation.Notes:
(1) Internet Explorer does not support transform-style:preserve-3d, thus limiting the nesting of animations.
transformations
perspective()function
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() function.
-
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 theperspective()function in the specification.March 03, 2020Working Draft.
See also, about the transformations.
The specification module "CSS Transforms Module" gathers all the properties and functions concerning CSS transformations:



