CSS PROPERTIES
Expand All | Collapse All
CSS AT-RULES
Advertisements

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:

perspective-origin: 
[ x-position y-position ] | initial | inherit

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.

.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:

  • percentage - Defines the offset relative to the width of the element.
  • length - Defines the offset using a length value.
  • left - Equal to 0% or a zero width.
  • center - Equal to 50% or half the width of the box.
  • right - Equal to 100% or the full box width.
y-position

Represents the vertical position (or offset) of the perspective origin. It can have one of the following values:

  • percentage - Defines the offset relative to the height of the element.
  • length - Defines the offset using a length value.
  • top - Equal to 0% or a zero height.
  • center - Equal to 50% or a half the height of the box.
  • bottom - Equal to 100% or the full box height.
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.

Browsers Icon

Basic Support—

  • Firefox 10+ -moz-, 16+
  • Google Chrome 12+ -webkit-, 36+
  • Internet Explorer 10+
  • Apple Safari 4.0.3+ -webkit-
  • Opera 15+ -webkit-, 23+

Further Reading

See tutorial on: CSS3 3D Transforms.

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

Advertisements
Bootstrap UI Design Templates Property Marvels - A Leading Real Estate Portal for Premium Properties