CSS | perspective() Function

The perspective() function is an inbuilt function in CSS which is used with transform property to set the perspective effect on images.

Syntax:

perspective( length );

Parameters: This function accepts single parameter length which is used to hold the value of perspective level. The length value represents the distance from user to z=0 plane. It is mandatory parameter.



Return value: It makes the image perspective on the basis of user define value.

Below example illustrates the perspective() function in CSS:

Example:

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE hyml>
<html>
  
<head>
    <title>
        CSS | perspective() function
    </title>
  
    <style>
        h1 {
            color: green;
        }
        .left {
            transform: perspective(400px) rotateY(70deg);
        }
    </style>
</head>
  
<body>
    <center>
        <h1>GeeksforGeeks</h1>
          
        <h4>CSS | perspective() function</h4>
          
        <div>
            <img class="left" src=
                alt="Sample image">
  
            <img class="right" src=
                alt="Sample image">
        </div>
    </center>
<body>
  
</html>

chevron_right


Output:
CSS perspective() function

Supported browser: The browser supported by CSS | perspective() function are listed below:

  • Google Chrome
  • Internet Explorer/ Microsoft Edge
  • Mozila Firefox
  • Safari
  • Opera


My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.