Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to set the 3D rotation center point by css3

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

In this article, the editor introduces in detail "css3 how to set 3D rotation center point". The content is detailed, the steps are clear, and the details are handled properly. I hope this "css3 how to set 3D rotation center point" article can help you solve your doubts.

In css3, you can use the "transform-origin" attribute to set the 3D rotation center point, which is used to change the position of the rotated element. The three parameters in the attribute set the position of the view relative to the X axis, Y axis, and Z axis, respectively, and the syntax is "transform-origin: x y z;".

The operating environment of this tutorial: windows10 system, CSS3&&HTML5 version, Dell G3 computer.

How to set the 3D rotation center point by css3

The transform-origin attribute allows you to change the location of the transformed element.

2D transformation elements can change the x and y axes of elements. 3D conversion elements can also change their Z axis.

When the transform-origin property is not set, the rotation, shift, scaling and other operations of the CSS deformation are all deformed at the center of the element (deformation origin / center point). The transform-origin attribute in CSS3 is used to set the base point position of the rotating element. Familiar with the use of transform-origin and combined with CSS3 animation, the element can be rotated along a certain base point, displacement, and so on.

Grammar

Transform-origin: x-axis y-axis z-axis

X-axis defines where the view is placed on the X axis. Possible values: left, center, right, length,%

Y-axis defines where the view is placed on the Y axis. Possible values: top, center, bottom, length,%

Z-axis defines where the view is placed on the Z axis. Possible value: length

3D cube rotation effect realized by CSS3

How to use it:

1. Call CSS style:

2. Add HTML code:

Will. Between html and js code; put in between.

HTML Code:

1 2 3 4 5 6

CSS 3 Code:

* {margin: 0moz-perspective:0px; padding: 0;} html,body {height: 100% moz-perspective:0px; background: black;} .wrap {height: 100% moz-perspective:0px; position: relative;-webkit-transform-style:preserve-3d;-webkit-perspective:0px;-moz-transform-style:preserve-3d;-moz-perspective:0px;-webkit-animation:mydhua 5s ease infinite;-moz-animation:mydhua 5s ease infinite;} .box {width: 200pxX height: 200pxscape position: absolute;top: 50% left: 50% Margin:-100px 00-100px; line-height: 200pxText: white;} .box1 {- webkit-transform:rotatey (90deg) translatez (- 100px);-moz-transform:rotatey (90deg) translatez (- 100px); background: rgba (128 webkit-transform:rotatey (90deg) translatez (100px);-moz-transform:rotatey (90deg) translatez (100px); background: rgba (255meme 255min. 5) } .box3 {- webkit-transform:rotatex (90deg) translatez (100px);-moz-transform:rotatex (90deg) translatez (100px); background: rgba (255pr 153 90deg .5);} .box4 {- webkit-transform:rotatex (90deg) translatez (- 100px);-moz-transform:rotatex (90deg) translatez (- 100px); background: rgba (0Med 204 255vol. 5);} .box5 {- webkit-transform: translatez (- 100px);-moz-transform:translatez (- 100px); background: rgba (153Jing 204J 255e .5) } .box6 {- webkit-transform: translatez (100px);-moz-transform:translatez (100px); background: rgba (0meme 255 Magi. 5); @-webkit-keyframes mydhua {0% {- webkit-transform:rotateX (0deg) rotateY (0deg) rotateZ (0deg);-webkit-transform-origin: center center;} 100% {- webkit-transform:rotateX (180deg) rotateY (180deg) rotateZ (180deg);-webkit-transform-origin: center center } @-moz-keyframes mydhua {0% {- moz-transform:rotateX (0deg) rotateY (0deg) rotateZ (0deg);-webkit-transform-origin: center center;} 100% {- moz-transform:rotateX (180deg) rotateY (180deg) rotateZ (180deg);-webkit-transform-origin: center center;}}

After reading this, the article "how to set the 3D rotation center point of css3" has been introduced. If you want to master the knowledge points of this article, you still need to practice and use it yourself. If you want to know more about related articles, welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 273

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report