Home  >  Article  >  Web Front-end  >  How to use rotate to set the rotation angle in css3

How to use rotate to set the rotation angle in css3

WBOY
WBOYOriginal
2022-01-24 15:47:302079browse

In css3, you can use the transform attribute with the rotate() function to set the rotation angle of the element. The transform attribute is used to specify the rotation, scaling and other operations of the element. The rotate() function is used to define the 2D rotation of the element. The syntax is " Element {transform:rotate(angle)}".

How to use rotate to set the rotation angle in css3

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

css3How to use rotate to set the rotation angle

The transform attribute applies 2D or 3D transformation to the element. This property allows us to rotate, scale, move or tilt the element.

This attribute can be used with the rotate() function to set the rotation angle.

The rotate() function defines 2D rotation and specifies the angle in the parameters.

The example is as follows:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <style>
  div{
    width:100px;
    height:100px;
    border:1px solid #000;
    transform:rotate(45deg);
  }
  </style>
</head>
<body>
  <div></div>
</body>
</html>

Output result:

How to use rotate to set the rotation angle in css3

(Learning video sharing: css video tutorial)

The above is the detailed content of How to use rotate to set the rotation angle 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