Home>Article>Web Front-end> How to set rotate at the rotation center point in css3

How to set rotate at the rotation center point in css3

WBOY
WBOY Original
2022-04-24 10:50:22 8847browse

In CSS3, you can use the "transform-origin" attribute to set the rotation center point of rotate. This attribute can change the position of the transformed element. The first parameter sets the rotation position of the x-axis, and the second parameter sets Y-axis rotation position, the syntax is "transform-origin:x-axis position y-axis position".

How to set rotate at the rotation center point in css3

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

How to set the rotation center point of rotate in css3

The rotate() function is a built-in function used to rotate elements based on a given angle as a parameter. Angle can be set in degrees, ticks, radians or turns.

Usage:

rotate( angle )

Parameters: This function accepts a single parameter angle representing the rotation angle. Positive and negative angles rotate the element clockwise and counterclockwise respectively.

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

Example 1:

   CSS rotate() function  
  

GeeksforGeeks

CSS rotate() function



GeeksforGeeks logo

Output:

How to set rotate at the rotation center point in css3

The transform-Origin attribute allows you to change the position of the transformed element.

2D transform elements can change the X and Y axes of the element. Transform elements in 3D and 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.

The example is as follows:

    123  
  
HELLO

Output result:

How to set rotate at the rotation center point in css3

(Learning video sharing:css video tutorial)

The above is the detailed content of How to set rotate at the rotation center point in css3. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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