Home > Web Front-end > CSS Tutorial > How to use perspective-origin attribute

How to use perspective-origin attribute

青灯夜游
Release: 2019-02-01 15:07:08
Original
4000 people have browsed it

The perspective-origin attribute is used to define the X-axis and Y-axis on which the 3D element is based, which allows changing the bottom position of the 3D element. When you define the perspective-origin attribute for an element, its child elements get the perspective effect, not the element itself.

How to use perspective-origin attribute

CSS3 perspective-origin attribute

Function: perspective-origin attribute Defines the X and Y axes on which the 3D element is based. This property allows you to change the bottom position of a 3D element. When you define the perspective-origin attribute for an element, its child elements get the perspective effect, not the element itself.

Syntax:

perspective-origin: x-axis y-axis;
Copy after login

x-axis: Define the position of the view on the x-axis. Default value: 50%. Possible values: left center right length %

y-axis: Defines the position of the view on the y-axis. Default value: 50%. Possible values: top center bottom length %

Note: This attribute must be used together with the perspective attribute, and only affects 3D transformation elements.

CSS3 perspective-origin attribute usage example

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"> 
<style>
#div1
{
position: relative;
height: 150px;
width: 150px;
margin: 50px;
padding:10px;
border: 1px solid black;
perspective:150;
perspective-origin: 10% 10%;
-webkit-perspective:150; /* Safari and Chrome */
-webkit-perspective-origin: 10% 10%; /* Safari and Chrome */
}
#div2
{
padding:50px;
position: absolute;
border: 1px solid black;
background-color: red;
transform: rotateX(45deg);
-webkit-transform: rotateX(45deg); /* Safari and Chrome */
}
</style>
</head>
<body>
<div id="div1">
  <div id="div2">HELLO</div>
</div>
 
</body>
</html>
Copy after login

Rendering:

How to use perspective-origin attribute

The above is the entire content of this article, I hope it will be helpful to everyone's study. For more exciting content, you can pay attention to the relevant tutorial columns of the PHP Chinese website! ! !

The above is the detailed content of How to use perspective-origin attribute. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template