Get the App
SLTechnology News&Howtos  ›  Development  › 

How to set the rotation center point of rotate in css3

Shulou Source: shulou.com Published: 2022-05-31 18:40:51 10月05日 Update

This article mainly explains "how to set the rotation center point of rotate in css3". The content of the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to set the rotation center point of rotate in css3".

In css3, you can set the rotation center point of the rotate with the "transform-origin" attribute, which changes the position of the conversion element, the first parameter sets the rotation position of the x-axis, the second parameter sets the y-axis rotation position, and the syntax is "transform-origin:x axis position y-axis position".

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

How to set the center of rotation of rotate in css3

The rotate () function is a built-in function that rotates the element based on a given angle. You can set the angle according to degrees, scales, radians or corners.

Usage:

Rotate (angle)

Parameters: this function accepts a single parameter angle that represents the rotation angle. Positive and negative angles make the element rotate clockwise and counterclockwise, respectively.

The following example illustrates the rotate () function in CSS:

Example 1:

CSS rotate () function body {text-align:center;} H2 {color:green;} .transform:rotate _ image {transform:rotate (45deg);} GeeksforGeeks CSS rotate () function

GeeksforGeeks logo

Output:

The transform-Origin attribute allows you to change the location of the transformation element.

A 2D transformation element can change the X and Y axes of an element. 3D converts the element, and you can also change the Z axis of the element.

The syntax is:

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

X-axis defines where the view is placed on the X axis.

Y-axis defines where the view is placed on the Y axis.

Examples are as follows:

123#div1 {position: relative;height: 200pxtoswidth: 200pxtransposition margin: 100pxtranspaddingrelative;height 10pxborder: 1px solid black;} # div2 {padding:50px;position: absolute;border: 1px solid black;background-color: red;transform: rotate (45deg); transform-origin:20% 40% transmissionmstransform: rotate (45deg); / * IE 9 * /-ms-transform-origin:20% 40%; / * IE 9 * /-webkit-transform: rotate (45deg) / * Safari and Chrome * /-webkit-transform-origin:20% 40%; / * Safari and Chrome * /} HELLO

Output result:

Thank you for your reading, the above is the content of "how to set the rotation center point of rotate in css3". After the study of this article, I believe you have a deeper understanding of how to set the rotation center point of rotate in css3. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Tags: Element center point position parameter function angle attribute learning content example view syntax output representative scale single that is degrees radians ideas Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple Shulou Tech Info macOS Shulou Information Huawei