CSS3 perspective-origin
Property
Topic: CSS3 Properties ReferencePrev|Next
Description
The perspective-origin
CSS property defines the origin (the vanishing point for the 3D space) for the perspective
property. It effectively sets the X and Y position at which the viewer appears to be looking at the children of the element.
The following table summarizes the usages context and the version history of this property.
Default value: | 50% 50% |
---|---|
Applies to: | Transformable elements |
Inherited: | No |
Animatable: | Yes. See animatable properties. |
Version: | New in CSS3 |
Syntax
The syntax of the property is given with:
Note: If only one value is specified for the perspective-origin
property, the second value is assumed to be center
, which is equal to 50%
value.
The example below shows the perspective-origin
property in action.
Example
Try this code ».container{
width: 125px;
height: 125px;
perspective: 300px;
perspective-origin: 20% top;
border: 4px solid #a2b058;
background: #f0f5d8;
}
.transformed {
-webkit-transform: rotate3d(0, 1, 0, 60deg); /* Chrome, Safari, Opera */
transform: rotate3d(0, 1, 0, 60deg); /* Standard syntax */
}
Note: If at least one of the two values is not a keyword, then the first value represents the horizontal position (or offset) and the second value represents the vertical position (or offset) of the perspective origin.
Property Values
The following table describes the values of this property.
Value | Description |
---|---|
x-position |
Represents the horizontal position (or offset) of the perspective origin. It can have one of the following values:
|
y-position |
Represents the vertical position (or offset) of the perspective origin. It can have one of the following values:
|
initial |
Sets this property to its default value. |
inherit |
If specified, the associated element takes the computed value of its parent element perspective-origin property. |
Browser Compatibility
The perspective-origin
property is supported in all major modern browsers.
Basic Support—
|
Further Reading
See tutorial on: CSS3 3D Transforms.
Related properties: perspective
, backface-visibility
, transform
, transform-origin
, transform-style
.