HTML DOM Style perspectiveOrigin Property

HTMLDOMWeb DevelopmentFront End Technology

The HTML DOM Style perspectiveOrigin property returns and modify where a 3D element is placed on x-axis and y-axis in an HTML document.


Following is the syntax −

1. Returning perspectiveOrigin


2. Modifying perspectiveOrigin

object.perspectiveOrigin = “value”

Here, value can be −

initialIt set this property value to its default value.
inheritIt inherits this property value from its parent element.
x-axis y-axisHere x-axis represent where the view is placed on the x-axis. y-axis represent where the view is placed on the y-axis.

Let us see an example of HTML DOM Style perspectiveOrigin Property −


<!DOCTYPE html>
   body {
      color: #000;
      height: 100vh;
      background-color: #8BC6EC;
      background-image: linear-gradient(135deg, #8BC6EC 0%, #9599E2 100%);
      perspective: 100px;
   .btn {
      background: #db133a;
      border: none;
      height: 2rem;
      border-radius: 2px;
      width: 40%;
      display: block;
      color: #fff;
      outline: none;
      cursor: pointer;
      margin: 1rem auto;
   .box {
      text-align: center;
      width: 200px;
      height: 200px;
      background-color: #db133a;
      transform: rotateX(25deg);
      margin: 2rem auto;
<h1 style="text-align:center">DOM Style perspectiveOrigin Property Demo</h1>
<div class='box'></div>
<button class="btn" onclick="set()">Set PerspectiveOrigin</button>
   function set() { = "20% 50%";


Click on “Set PerspectiveOrigin” button to set perspective origin of red box.

Published on 23-Sep-2019 15:20:59