Open In App

CSS perspective-origin Property

The perspective-origin property in CSS is used to define the position at which the user is looking 3D object i.e. the vanishing point of the 3D object. 

Syntax:



perspective-origin: x-axis y-axis|initial|inherit;

Property Values:

Example: 






<!DOCTYPE html>
<html>
 
<head>
    <title>
        CSS perspective-origin Property
    </title>
     
    <style>
        .container1 {
            padding: 20px;
            perspective: 100px;
            perspective-origin: 75%;
             
            /* For Safari Browsers */
            -webkit-perspective: 100px;
            -webkit-perspective-origin: 75%;
        }
        .container2 {
            padding: 20px;
            perspective: 100px;
            perspective-origin: bottom right;
             
            /* For Safari Browsers */
            -webkit-perspective: 100px;
            -webkit-perspective-origin: bottom right;
        }
        .container3 {
            padding: 20px;
            perspective: 100px;
            perspective-origin: center;
             
            /* For Safari Browsers */
            -webkit-perspective: 100px;
            -webkit-perspective-origin: center;
        }
        .rotate {
            width: 100px;
            padding: 50px;
            text-align: center;
            background: green;
            transform: rotateX(10deg);
        }
    </style>
</head>
             
<body>
    <div class = "container1">
         
        <p>perspective-origin: 75%;</p>
         
        <div class = "rotate">image</div>
         
    </div>
     
    <div class = "container2">
         
        <p>perspective-origin: bottom right;</p>
         
        <div class = "rotate">image</div>
         
    </div>
     
    <div class = "container3">
         
        <p>perspective-origin: center;</p>
         
        <div class = "rotate">image</div>
         
    </div>
</body>
 
</html>                               

Output:

  

Supported Browsers: The browser supported by perspective-origin property are listed below:


Article Tags :