前端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>
相关推荐
咘噜biu1 分钟前
Java后端和前端的接口数据加密方案(椭圆曲线集成加密方案)
java·前端·安全·aes·密钥协商ecdh·椭圆曲线集成加密方案
CodeSheep5 分钟前
百度又一知名产品,倒下了!
前端·后端·程序员
阿芯爱编程6 分钟前
前端面试题linux操作
前端·面试
Bug.ink20 分钟前
BUUCTF——WEB(4)
前端·网络安全·靶场·ctf·buuctf
L Jiawen21 分钟前
【Web】RESTful风格
前端·后端·restful
爱编码的傅同学26 分钟前
【单例模式】深入理解懒汉与饿汉模式
java·javascript·单例模式
momo(激进版)27 分钟前
前端打包时自动更新版本号
前端
胖虎132 分钟前
UIKit实现一个渐变文字的UILabel(核心思想及实现过程)
前端·mask·渐变文字·ios渐变文字·渐变label
用户68026590511934 分钟前
2026年企业级网络监控选型指南
javascript·后端·面试
alphardex41 分钟前
一个普通魔法师的 2025 年度总结
前端·年终总结