0064 2D转换综合写法以及顺序问题:translate rotate scale

2D 转换综合写法以及顺序问题
  1. 知识要点

    • 同时使用多个转换,其格式为 transform: translate() rotate() scale()
    • 顺序会影响到转换的效果(先旋转会改变坐标轴方向)
    • 但我们同时有位置或者其他属性的时候,要将位移放到最前面
  2. 代码演示

    div:hover {
      transform: translate(200px, 0) rotate(360deg) scale(1.2)
    }
<!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: 200px;
            height: 200px;
            background-color: pink;
            transition: all .5s;
        }
        
        div:hover {
            /* transform: rotate(180deg) translate(150px, 50px); */
            /* 我们同时有位移和其他属性,我们需要把位移放到最前面 */
            transform: translate(150px, 50px) rotate(180deg) scale(1.2);
        }
    </style>
</head>

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

</html>

猜你喜欢

转载自www.cnblogs.com/jianjie/p/12127179.html