0061 CSS3 rotate the 2D conversion

  1. rotate rotation

    • 2D Rotate the thumb is to allow two-dimensional plane elements in a clockwise or counterclockwise rotation
  2. rotateSyntax using the steps:
    (1) adding to the attribute conversion element transform
    (2) attribute value rotate(角度), such as transform:rotate(30deg)clockwise 30 degrees

   /* 单位是:deg */
   transform: rotate(度数) 
div{
      transform: rotate(0deg);
}
  1. Key knowledge points

    • rotate With degrees inside the unit is deg
    • When the angle is positive, clockwise, the angle is negative, counterclockwise
    • The default rotation center point is the center point of the element
  2. Code demonstrates

    img:hover {
      transform: rotate(360deg)
    }
<!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>
        img {
            width: 150px;
            /* 顺时针旋转45度 */
            /* transform: rotate(45deg); */
            border-radius: 50%;
            border: 5px solid pink;
            /* 过渡写到本身上,谁做动画给谁加 */
            transition: all 0.3s;
        }
        
        /* 这里不能写成 div:hover,否则鼠标悬停时,图片会快速闪。 */
        img:hover {
            transform: rotate(360deg);
        }
    </style>
</head>

<body>
    <img src="media/pic.jpg" alt="">
</body>

</html>

Here Insert Picture Description

Triangle Case
<!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 {
            position: relative;
            width: 249px;
            height: 35px;
            border: 1px solid #000;
        }
        
        div::after {
            content: "";
            position: absolute;
            top: 8px;
            right: 15px;
            width: 10px;
            height: 10px;
            border-right: 1px solid #000;
            border-bottom: 1px solid #000;
            transform: rotate(45deg);
            transition: all 0.2s;
        }
        /* 鼠标经过div  里面的三角旋转 */
        div:hover::after {
            transform: rotate(225deg);
        }
    </style>
</head>

<body>
    <div></div>
</body>

</html>

Here Insert Picture Description
Here Insert Picture Description

Guess you like

Origin www.cnblogs.com/jianjie/p/12127155.html