perspective() CSS Function
The perspective() transform function gives 3D transforms depth by setting the distance between the viewer and the z = 0 plane.
Description
The perspective() CSS function is a transform function that applies a 3D perspective to the element it is used on. It sets the distance between the viewer and the plane where the element sits (z = 0), so that parts of the element that are rotated or moved toward the viewer look larger, and parts moved away look smaller. It is used inside the transform property, together with 3D transform functions such as rotateX(), rotateY() and translateZ().
The argument is a length, such as 500px. A smaller value means the viewer is closer, which gives a stronger, more dramatic 3D effect; a larger value gives a subtler effect. The keyword none, or a value of 0, means no perspective is applied. Because transform functions are applied from left to right, perspective() must come before the functions it should affect, for example transform: perspective(600px) rotateY(30deg).
The perspective() function is different from the perspective property. The function only affects the element it is applied to, and each element gets its own vanishing point. The property is set on a parent and gives all of its 3D-transformed children a shared vanishing point, which looks more natural for groups of elements such as a 3D carousel. The vanishing point used by the property can be moved with perspective-origin.
/* Perspective applied to a single element */
.card {
transform: perspective(600px) rotateY(25deg);
}
/* Equivalent effect for a group: set the property on the parent */
.scene {
perspective: 600px;
}
.scene .card {
transform: rotateY(25deg);
}
Interactive Demo
Syntax
perspective() = perspective( [ <length [0,∞]> | none ] )
Values
- sizeIs a <length> representing the distance from the user to the z=0 plane. If it is 0 or a negative value, no perspective transform is applied.
Example
Browser Support
The following information will show you the current browser support for the CSS perspective() function. Hover over a browser icon to see the version that first introduced support for this CSS function.
Desktop





Tablets & Mobile





