CSS3 3D Transform Transform

Source: Internet
Author: User

The coordinates of the transform are attributes that need to be understood.

Our Rotatex,rotatey,rotatez, and Translatex,translatey, are positioned based on the same coordinate system.

The coordinates of the 3D are as follows:

The following three methods are available in the 3D transform:

    • rotateX( angle )
    • rotateY( angle )
    • rotateZ( angle )

Understand the three methods, the later more difficult to understand the perspective good, can be said to be a breakthrough!

rotateRotate the x-axis, rotate the y-axis, rotate the z-axis, rotateX rotateY rotateZ where:

They use the angle value as the parameter. If it is a positive angle, the element rotates clockwise. If it is a negative angle, the element rotates counterclockwise.

2. Essential Perspective Attributes

   perspectiveThe existence of a property determines whether you see a 2-or 3-dimensional, that is, 2D transform or 3D transform.

We look at Demo1:

 <!    DOCTYPE html> #div1 {position:relative;    height:150px;    width:150px;    margin:50px;    padding:10px;    BORDER:1PX solid black;     /*  PERSPECTIVE:150; -webkit-perspective:150; /* Safari and Chrome  */ */} #div2 {padding    : 50px;    Position:absolute;    BORDER:1PX solid black;    Background -color:yellow;    Transform:rotatex (45DEG); -webkit-transform:rotatex (45DEG); /*   Safari and Chrome  */   </style>

Whether to add the perspective property , the following styles are displayed:

&&

We need to know:

CSS3 3D Transform's pivot point is in front of the browser !

Or do you understand that: the perspective Point of the 3D effect element in the display is above the monitor (not the back), which is approximately where our eyes are !

Like what:

A 1680-pixel-wide display has a beautiful picture, applied 3D transform, and the element or the element's parent element is set to a perspective size of 2000 pixels.

The beauty of this beautiful multi-3D effect is the same as you personally in 1.2 display width of the place (1680*1.2≈2000) See the true effect of the same!!

  perspectiveA property has two forms of writing, one used on the stage element (the common ancestor element of the animated element), and the second is written on the current animated element, with other properties of the transform. The following code example:

Demo2 as follows:

. container {  display:block;  width:200px;  height:200px;  Margin-bottom:50px;  border:1px solid #bbb;}. box {  100%;   100%;  Opacity:. (a);} #darkred. Box {  background-color:darkred;  Transform:perspective (600px) Rotatey (45deg);} #darkblue {  perspective:600px;} #darkblue. Box {  background-color:darkblue;  Transform:rotatey (45deg);} </style>

As follows:

There is a big difference in the effect of these two formulations:

The above stage is the whole as a perspective element, so, obviously, we see the shape of each child element is not the same;

And below, each element has its own viewpoint, so, obviously, because the rotatey angle is the same, so the effect looks exactly the same!

Perspective-origin

  perspective-originThis property is very well understood and represents the position of your double-eyed eyes. The default is the center of the stage or element you are looking at.

Transform-style:preserve-3d

transform-styleProperties are also commonly used in 3D effects, with two parameters flat|preserve-3d .

The former flat is the default value, which represents the plane, and the latter preserve-3d represents a 3D perspective.

Basically, we want to achieve some 3D effects based on real-world experience transform-style: preserve-3d .

In general, the Declaration is applied to the parent element of the 3D transform's sibling element, the stage element.

CSS3 3D Transform Transform

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.