前端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>
相关推荐
做前端的娜娜子30 分钟前
同一链接实现 PC Web 与移动 H5 自适应
前端·掘金·金石计划
小帅不太帅37 分钟前
架构没变、规模没变,DeepSeek V4 Flash 正式版凭什么暴涨 47 分?
前端·aigc·deepseek
jarvisuni1 小时前
DeepSeekFlash前端依旧拉垮,而且变慢了很多!
前端·javascript·算法
卷福同学2 小时前
AI编程出海第二步:验证关键词能否做站
前端·人工智能·后端
先吃饱再说2 小时前
编写一个颜色选择器之后,我理解了 React 工程化的三层架构
react.js·前端框架·前端工程化
先吃饱再说3 小时前
别说你懂 useEffect:从底层机制到生命周期管理,这篇全讲透了
react.js·前端框架
开普勒chr3 小时前
css样式diaplay:"contents"的妙用
css
赵庆明老师3 小时前
Vben精讲:21-详解web-antd:tsconfig.json
前端·json·vim
先吃饱再说3 小时前
从“传事件”到“只传值”:React + TypeScript 组件 Props 设计的两次进化
react.js·前端框架·前端工程化