前端css动画transform多个属性值写法

X轴平移400px transform: translateX(400px);

X轴平移400px并缩小0.5倍 transform: translateX(400px) scale(0.5);

X轴平移400px并旋转45度 transform: translateX(400px) rotate(45deg);

直接空格直接加属性即可

建议写的时候先平移

html 复制代码
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box1{
            width: 600px;
            height: 600px;
            border: 2px solid gray;
        }
        .box1 div{
            width: 100px;
            height: 100px;
            border: 2px solid gray;
            background: red;
        }
        .box1 div:nth-child(1){
            transform: translateX(400px);
            /* X轴平移400px */
        }
        .box1 div:nth-child(2){
            transform: translateX(400px) scale(0.5);
            /* X轴平移400px并缩小0.5倍 */
        }
        .box1 div:nth-child(3){
            transform: translateX(400px) rotate(45deg);
            /* X轴平移400px并旋转45度 */
        }
    </style>
</head>
<body>
    <div class="box1">
        <div> X轴平移400px</div>
        <div>X轴平移400px并缩小0.5倍</div>
        <div>X轴平移400px并旋转45度</div>
    </div>
</body>
</html>
相关推荐
陈随易1 小时前
C++26 草案被否,二十八年来头一回
前端·后端·程序员
ZhengEnCi1 小时前
Agent 工具怎么折叠海量输出才「爽」:Trae、Claude Code 的渐进式披露设计原理
前端·agent
Penge6661 小时前
《Go 后端开发者学 React:useState》
javascript
Penge6662 小时前
《Go 后端开发者学 React:数据渲染》
javascript
IT_陈寒4 小时前
Redis内存暴涨,没想到是AOF重写捣的鬼
前端·人工智能·后端
ikoala4 小时前
让 Codex 自己查账:一个省 token 的小技巧
前端·后端·ai编程
ikoala5 小时前
AI 写页面像说明书,修 Bug 像贴膏药?把这两句话写进 AGENTS.md
前端·javascript·ai编程
Penge6665 小时前
《Go 后端开发者学 TypeScript:ES Module了解》
javascript
Penge6665 小时前
《Go 后端开发者学 TypeScript:从零搭建与运行》
javascript
Penge6666 小时前
《Go 后端开发者学 TypeScript:keyof关键字》
javascript