English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

CSS Reference Manual

CSS @rules (RULES)

Comprehensive List of CSS Properties

CSS3 Usage and examples of perspective property

The perspective CSS property defines the perspective for all child elements of the viewing object. It usually determines the distance between the Z = 0 plane and the viewer, in order to give3Position the element with a sense of depth. Each Z > 0 element3The D element becomes larger, while each Z < 0 element3The D element becomes smaller.

The following table provides usage instructions and version history of this attribute, as well as its usage syntax in JavaScript scripts.

Default value:none
Applies to:Transformable elements
Inheritance:No
Animatable:Yes.Please refer to Animation properties.
Version: CSS3new feature
JavaScript syntax:object.style.perspective=500

Perspective usage syntax

The syntax of this attribute is as follows:

perspective: length | none | initial | inherit

The following example demonstrates how to use the perspective attribute.

.container {
    width: 125px;
    height: 125px;
    perspective: 500px;
    border: 4px solid #e5a043;
    background: #fff2dd;
}
.transformed {
    -webkit-transform: translate3d(25px, 25px, 50px); /* Chrome, Safari, Opera */
    transform: translate3d(25px, 25px, 50px); 
}
Test and see‹/›

Attribute value

The following table describes the value of this attribute.

ValueDescription
lengthIndicates the length value of the perspective depth. If it is 0 or negative, the perspective transformation will not be applied.
noneNo perspective transformation needs to be applied. This is the default value.
initialSet this attribute to its default value.
inheritIf specified, the associated elements will adopt the attribute value of their parent element's perspective.

Browser compatibility

The compatibility of the perspective attribute in browsers, the numbers in the following table represent the minimum version number of browsers that support this attribute; all mainstream browsers support this attribute.

  • Firefox 10+ -moz-,16 +

  • Google Chrome 12+ -webkit-,36+

  • Internet Explorer 10+

  • Apple Safari 4.0.3+ -webkit-

  • Opera 15+ -webkit-,23+

For further reading

Please refer to the following tutorial:CSS3 3D transformation.

Related attributes:perspective-origin,backface-visibility,transform,transform-origin,transform-style.