前端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>
相关推荐
ruanCat28 分钟前
Prettier 明明执行成功,Markdown 为什么还是没变?一次插件误诊复盘
前端·javascript·node.js
软件开发技术深度爱好者37 分钟前
在线学习实践 TypeScript 的官方Playground(演练场)使用介绍
javascript·学习·typescript
百变梦仔1 小时前
Codex 写前端任务时,我用这张 GitHub Skill 地图先选工具
前端·github
2601_962122971 小时前
nginx 部署前端vue项目
前端·vue.js·nginx
雪芽蓝域zzs2 小时前
第三节:目录结构重构(仿若依,优化层级,layout 与 components 同级)
前端·vue.js·重构