CSS perspective-origin Property

The CSS perspective-origin property sets the position of the viewpoint used to observe child elements in a three-dimensional CSS scene.

It works with the perspective property to control how transformed elements appear from different viewing positions. Moving the perspective origin changes the apparent direction of the 3D projection without changing the actual position or rotation of the elements.

perspective-origin Syntax

The perspective-origin property accepts one or two position values. These values determine the horizontal and vertical coordinates of the perspective viewpoint.

Basic Syntax

selector {
  perspective-origin: center center;
}

This places the viewpoint at the center of the perspective container.

Single-Value Syntax

.scene {
  perspective-origin: left;
}
.scene {
  perspective-origin: right;
}
.scene {
  perspective-origin: center;
}
.scene {
  perspective-origin: 30%;
}

A single value specifies the horizontal position. The vertical position defaults to center.

Two-Value Syntax

.scene {
  perspective-origin: left top;
}
.scene {
  perspective-origin: right bottom;
}
.scene {
  perspective-origin: 25% 75%;
}
.scene {
  perspective-origin: 100px 50px;
}

The first value specifies the horizontal position, and the second specifies the vertical position. When using two keywords, a vertical keyword may also appear first.

CSS-Wide Keywords

.scene {
  perspective-origin: initial;
}
.scene {
  perspective-origin: inherit;
}
.scene {
  perspective-origin: unset;
}
.scene {
  perspective-origin: revert;
}
.scene {
  perspective-origin: revert-layer;
}

CSS-wide keywords must be used individually and cannot be combined with position values.

Property Values

Value Description
left Positions the viewpoint at the left edge of the container. Equivalent to 0% horizontally.
center Positions the viewpoint at the center of the specified axis. Equivalent to 50%.
right Positions the viewpoint at the right edge of the container. Equivalent to 100% horizontally.
top Positions the viewpoint at the top edge of the container. Equivalent to 0% vertically.
bottom Positions the viewpoint at the bottom edge of the container. Equivalent to 100% vertically.
<length> Specifies an offset using a CSS length such as px, em, or rem.
<percentage> Specifies a position relative to the dimensions of the perspective container.
initial Resets the property to 50% 50%.
inherit Uses the computed value from the parent element.
unset Resets the property to 50% 50% because it is not inherited.
revert Reverts the property according to CSS cascade origin rules.
revert-layer Reverts the property according to CSS cascade layer rules.

Property Characteristics

Characteristic Value
Initial value 50% 50%
Inherited No
Applies to Transformable elements
Computed value Absolute lengths or percentages
Animation type By computed value type
Percentages Relative to the width and height of the element's reference box
Default horizontal position 50%
Default vertical position 50%
Related property perspective

Valid Values

.scene {
  perspective-origin: center;
}
.scene {
  perspective-origin: left top;
}
.scene {
  perspective-origin: bottom right;
}
.scene {
  perspective-origin: 25% 75%;
}
.scene {
  perspective-origin: -50px 120%;
}
.scene {
  perspective-origin: calc(50% + 20px) center;
}

Negative lengths and percentages outside the 0% to 100% range are valid. They position the viewpoint outside the reference box.

Invalid Values

.scene {
  perspective-origin: auto;
}
.scene {
  perspective-origin: left right;
}
.scene {
  perspective-origin: top bottom;
}
.scene {
  perspective-origin: 20px 30px 40px;
}
.scene {
  perspective-origin: 100;
}

The property does not accept auto, conflicting keywords on the same axis, three position values, or nonzero unitless numbers.

How It Works

The perspective-origin property determines where the viewer is positioned horizontally and vertically relative to a perspective container.

Default Centered Viewpoint

.scene {
  perspective: 600px;
  perspective-origin: center center;
}

The viewpoint is centered on the container. This is the default behavior.

Moving the Viewpoint

.scene {
  perspective: 600px;
  perspective-origin: left center;
}

The viewpoint shifts toward the left side of the container, changing how transformed children are projected.

Moving Outside the Container

.scene {
  perspective: 600px;
  perspective-origin: -100px 50%;
}

The viewpoint is positioned 100 pixels to the left of the container's reference box.

Perspective Origin Does Not Move Elements

Changing the perspective origin does not alter the layout position of child elements. It changes the viewpoint used to project their 3D transformations.

Perspective Is Required

The property has no visible effect when perspective is none. A perspective projection and suitable 3D transformations are needed to reveal the viewpoint change.

Important Distinction

The perspective origin is a viewing position, not the center of rotation. The center of rotation is controlled by transform-origin.

Horizontal Viewpoint Positioning

The horizontal component determines whether the 3D scene is viewed from the left, center, right, or another horizontal position.

Left Viewpoint

.scene {
  perspective: 600px;
  perspective-origin: left center;
}

The viewpoint is aligned with the left edge of the container.

Centered Viewpoint

.scene {
  perspective: 600px;
  perspective-origin: center center;
}

The viewpoint is aligned with the horizontal center of the container.

Right Viewpoint

.scene {
  perspective: 600px;
  perspective-origin: right center;
}

The viewpoint is aligned with the right edge of the container.

Custom Horizontal Position

.scene {
  perspective: 600px;
  perspective-origin: 30% center;
}

The viewpoint is positioned 30% of the way across the container from its left edge.

Horizontal Position Outside the Container

.scene {
  perspective: 600px;
  perspective-origin: 125% center;
}

The viewpoint is positioned beyond the right edge of the container.

Vertical Viewpoint Positioning

The vertical component determines whether the scene is viewed from the top, center, bottom, or another vertical position.

Top Viewpoint

.scene {
  perspective: 600px;
  perspective-origin: center top;
}

The viewpoint is aligned with the top edge of the container.

Centered Viewpoint

.scene {
  perspective: 600px;
  perspective-origin: center center;
}

The viewpoint is aligned with the vertical center of the container.

Bottom Viewpoint

.scene {
  perspective: 600px;
  perspective-origin: center bottom;
}

The viewpoint is aligned with the bottom edge of the container.

Custom Vertical Position

.scene {
  perspective: 600px;
  perspective-origin: center 25%;
}

The viewpoint is positioned one-quarter of the way down the container.

Vertical Position Outside the Container

.scene {
  perspective: 600px;
  perspective-origin: center -50px;
}

The viewpoint is positioned 50 pixels above the container's reference box.

Lengths and Percentages

The perspective-origin property supports CSS lengths, percentages, and combinations of the two.

Percentage Values

.scene {
  perspective-origin: 25% 75%;
}

The horizontal position is 25% of the container's reference-box width, and the vertical position is 75% of its height.

Pixel Values

.scene {
  perspective-origin: 100px 50px;
}

The viewpoint is positioned 100 pixels from the left edge and 50 pixels from the top edge.

Relative Length Units

.scene {
  perspective-origin: 5rem 3rem;
}

Relative length units can be useful when the viewpoint should respond to font sizing or other layout measurements.

Mixed Units

.scene {
  perspective-origin: 30% 40px;
}

Horizontal and vertical positions can use different unit types.

Calculated Positions

.scene {
  perspective-origin: calc(50% + 40px) calc(50% - 20px);
}

The calc() function can combine percentages and lengths to position the viewpoint relative to the center.

Reference Box

Percentages are resolved against the dimensions of the element's reference box, which can be affected by transform-box.

Important Consideration

Unlike the perspective property, which does not accept percentages, perspective-origin commonly uses percentages for viewpoint positioning.

Relationship With perspective

The perspective and perspective-origin properties work together to define how a three-dimensional scene is viewed.

Perspective Distance

.scene {
  perspective: 500px;
}

The perspective distance controls the strength of the 3D projection.

Perspective Viewpoint

.scene {
  perspective: 500px;
  perspective-origin: left top;
}

The perspective origin determines the horizontal and vertical viewing position.

Combining Both Properties

.scene {
  perspective: 800px;
  perspective-origin: 25% 50%;
}
.card {
  transform: rotateY(40deg);
}

The card rotates in 3D space while the parent supplies the perspective distance and viewpoint.

Different Perspective Distances

.scene-one {
  perspective: 300px;
  perspective-origin: center;
}
.scene-two {
  perspective: 1200px;
  perspective-origin: center;
}

The viewpoint remains centered, but the shorter perspective distance produces stronger depth distortion.

Different Perspective Origins

.scene-one {
  perspective: 600px;
  perspective-origin: left center;
}
.scene-two {
  perspective: 600px;
  perspective-origin: right center;
}

The perspective distance remains the same, but the viewing position changes.

Important Consideration

Changing the perspective distance and changing the perspective origin produce different effects. One controls depth strength, while the other controls the viewpoint position.

perspective-origin vs. transform-origin

The perspective-origin and transform-origin properties affect different parts of a 3D transformation.

perspective-origin

.scene {
  perspective: 600px;
  perspective-origin: left center;
}

This positions the viewpoint at the left side of the perspective container.

transform-origin

.card {
  transform-origin: left center;
  transform: rotateY(45deg);
}

This makes the card rotate around its left edge rather than its center.

Using Both Properties

.scene {
  perspective: 700px;
  perspective-origin: right center;
}
.card {
  transform-origin: left center;
  transform: rotateY(45deg);
}

The scene is viewed from the right, while the card rotates around its left edge.

Property Comparison

Property Purpose
perspective Sets the distance between the viewer and the projection plane.
perspective-origin Positions the perspective viewpoint horizontally and vertically.
transform-origin Sets the origin around which an element is transformed.
transform Applies transformations such as rotation, translation, and scaling.

Important Distinction

Moving the viewpoint does not move the rotation origin. The two properties can be adjusted independently.

Shared Viewpoints in 3D Scenes

When several transformed elements share the same perspective container, they are projected using a common perspective distance and viewpoint.

Multiple Cards in One Scene

<div class="scene">
  <div class="card card-one">Card One</div>
  <div class="card card-two">Card Two</div>
  <div class="card card-three">Card Three</div>
</div>
.scene {
  display: flex;
  gap: 20px;
  perspective: 800px;
  perspective-origin: center top;
}
.card-one {
  transform: rotateY(-30deg);
}
.card-two {
  transform: translateZ(40px);
}
.card-three {
  transform: rotateY(30deg);
}

Each card has its own transformation, but all three use the perspective projection established by the parent.

Separate Perspective Containers

.scene-left {
  perspective: 800px;
  perspective-origin: left center;
}
.scene-right {
  perspective: 800px;
  perspective-origin: right center;
}

Separate containers can establish different viewpoints for otherwise identical transformations.

Nested 3D Elements

.scene {
  perspective: 800px;
  perspective-origin: center;
}
.card-group {
  transform-style: preserve-3d;
}
.card-face {
  transform: translateZ(40px);
}

The transform-style: preserve-3d declaration allows nested descendants to retain their 3D positions when the surrounding rendering conditions permit it.

Important Consideration

Use a shared perspective container when multiple objects should appear to belong to the same three-dimensional scene.

perspective-origin Example

The following example compares three viewpoint positions while keeping the perspective distance and card rotation the same.

HTML Example

<div class="origin-demo">
  <div class="origin-item">
    <h3>Left Viewpoint</h3>
    <div class="origin-scene origin-left">
      <div class="origin-card">Left</div>
    </div>
  </div>
  <div class="origin-item">
    <h3>Center Viewpoint</h3>
    <div class="origin-scene origin-center">
      <div class="origin-card">Center</div>
    </div>
  </div>
  <div class="origin-item">
    <h3>Right Viewpoint</h3>
    <div class="origin-scene origin-right">
      <div class="origin-card">Right</div>
    </div>
  </div>
</div>

CSS Example

.origin-demo {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
}
.origin-item {
  flex: 1 1 180px;
  text-align: center;
}
.origin-scene {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 160px;
  perspective: 400px;
}
.origin-card {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 120px;
  height: 100px;
  background-color: #2563eb;
  border: 2px solid #1e40af;
  color: #ffffff;
  font-weight: 700;
  transform: rotateY(45deg);
}
.origin-left {
  perspective-origin: left center;
}
.origin-center {
  perspective-origin: center center;
}
.origin-right {
  perspective-origin: right center;
}
Browser Result

Left Viewpoint

Left

Center Viewpoint

Center

Right Viewpoint

Right

Each card uses rotateY(45deg) and a perspective distance of 400px. The visible differences come from the horizontal position of the perspective origin.

Expected Behavior

Value Effect
left center Projects the transformed card from a viewpoint aligned with the left edge.
center center Projects the card from a centered viewpoint.
right center Projects the transformed card from a viewpoint aligned with the right edge.

Practical Interactive Example

.interactive-scene {
  perspective: 700px;
  perspective-origin: center;
  transition: perspective-origin 0.4s ease;
}
.interactive-scene:hover {
  perspective-origin: 75% 25%;
}
.interactive-scene .card {
  transform: rotateY(35deg);
}
@media (prefers-reduced-motion: reduce) {
  .interactive-scene {
    transition: none;
  }
}

This changes the viewpoint when the scene is hovered. The card's rotation remains unchanged, but its perspective projection changes.

Accessibility Considerations

Perspective viewpoint changes can enhance visual presentation, but strong or animated 3D effects may make content difficult to read or uncomfortable for some users.

Respect Reduced-Motion Preferences

@media (prefers-reduced-motion: reduce) {
  .animated-scene {
    animation: none;
    transition: none;
  }
}

Use prefers-reduced-motion to reduce or remove unnecessary viewpoint animations.

Maintain Readable Content

Avoid viewpoint positions that cause excessive distortion of text or important interface elements.

Preserve Keyboard Accessibility

Interactive controls inside transformed elements should remain accessible by keyboard. Do not depend solely on hover to reveal essential content.

Avoid Unnecessary Motion

Rapidly changing perspective origins can create uncomfortable visual movement. Use restrained effects and avoid continuous motion when it serves no functional purpose.

Maintain Logical Reading Order

Perspective transformations do not change the HTML source order. Keep the document structure logical and meaningful.

Important Consideration

Perspective effects should support the interface rather than interfere with reading, navigation, or understanding.

Common Mistakes

Using perspective-origin Without perspective

.scene {
  perspective-origin: left center;
}

Without a perspective projection, changing the perspective origin has no visible effect.

Expecting the Property to Rotate Elements

The property changes the viewpoint, not the element's rotation. Use transform to rotate or move elements in 3D space.

Confusing perspective-origin With transform-origin

perspective-origin positions the viewpoint, while transform-origin controls the origin of an element's transformation.

Using auto

.scene {
  perspective-origin: auto;
}

The auto keyword is invalid.

Using Conflicting Keywords

.scene {
  perspective-origin: left right;
}

Both keywords specify horizontal positions, so the declaration is invalid.

Using Three Position Values

.scene {
  perspective-origin: 20px 30px 40px;
}

The property accepts one or two position values, not three.

Using Nonzero Unitless Numbers

.scene {
  perspective-origin: 100 50;
}

Nonzero numeric offsets require valid CSS length units or percentages.

Assuming Percentages Are Invalid

Unlike perspective, the perspective-origin property accepts percentages.

Assuming Values Must Stay Inside the Container

Negative values and percentages greater than 100% are valid and can position the viewpoint outside the reference box.

Ignoring the Reference Box

Percentage positions depend on the element's reference box. Changes to the container's dimensions or transform-box can affect the resulting viewpoint.

Applying the Property to the Wrong Element

Apply perspective-origin to the perspective container, not merely to a child being rotated.

Important Considerations

Keep the following points in mind when using perspective-origin:

  • It controls the horizontal and vertical position of the perspective viewpoint.
  • Its initial value is 50% 50%.
  • The property is not inherited.
  • It accepts one or two position values.
  • A single value sets the horizontal position and centers the vertical position.
  • Two values can specify both horizontal and vertical positions.
  • Horizontal keywords include left, center, and right.
  • Vertical keywords include top, center, and bottom.
  • CSS lengths and percentages are supported.
  • Negative lengths are valid.
  • Percentages outside the 0% to 100% range are valid.
  • The property does not accept auto.
  • Conflicting keywords on the same axis are invalid.
  • The property does not accept three position values.
  • It works with the perspective property.
  • It has no visible effect when perspective is none.
  • Suitable 3D transformations are needed to reveal changes in viewpoint.
  • It changes the viewpoint rather than the actual layout position of child elements.
  • It does not control the rotation origin.
  • The transform-origin property controls the origin of transformations.
  • The perspective property controls the strength of the perspective projection.
  • Percentage positions are relative to the element's reference box.
  • The transform-box property can affect the reference box used for positioning.
  • Multiple transformed children can share a common perspective viewpoint.
  • The property can be animated between compatible position values.
  • Animated viewpoint changes should respect reduced-motion preferences.
  • Extreme viewpoint positions can make transformed content difficult to read.
  • Perspective changes visual rendering without changing HTML reading order.

Browser Support

The CSS perspective-origin property is Widely available in modern browsers, including Chrome, Edge, Firefox, and Safari.

Support for CSS 3D transformations is well established. Complex nested 3D scenes and rendering details may vary between browsers, so advanced perspective effects should be tested in the intended environments.

For current compatibility information, visit Can I Use? and search for perspective-origin.

Specifications

The perspective-origin property is defined in CSS Transforms Module Level 2.

CSS Transforms Module Level 2

The specification defines how perspective viewpoints are positioned and how they affect the projection of three-dimensional transformations.

For additional documentation and examples, consult MDN Web Docs.

MDN Web Docs: perspective-origin