English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
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 |
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‹/›
The following table describes the value of this attribute.
Value | Description |
---|---|
length | Indicates the length value of the perspective depth. If it is 0 or negative, the perspective transformation will not be applied. |
none | No perspective transformation needs to be applied. This is the default value. |
initial | Set this attribute to its default value. |
inherit | If specified, the associated elements will adopt the attribute value of their parent element's perspective. |
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.
|
Please refer to the following tutorial:CSS3 3D transformation.
Related attributes:perspective-origin,backface-visibility,transform,transform-origin,transform-style.