zoukankan      html  css  js  c++  java
  • css二维动画

    <!DOCTYPE html>
    <html lang="en">
    
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Document</title>
        <style>
            * {
                padding: 0;
                margin: 0;
            }
    
            div {
                width: 100px;
                height: 100px;
                background-color: red;
                margin-left: 200px;
                margin-top: 10px;
                /* 添加过渡动画  css样式 名称 耗时*/
                transition: transform 2s;
            }
    
            /* 移动translate */
            div:first-of-type:active {
                /* 使用translate 可以实现元素的移动: 
                a.移动参照元素的左上角 b.执行完毕以后恢复到原来的状态 
                如果是一个参数表示x轴
                若果是两个参数就代表直角坐标系
                */
                /* 通常在设置的时候使用x和y */
                transform: translateX(300px);
                transform: translateY(300px);
            }
    
            /* 缩放:scale */
            div:nth-of-type(2):active {
                /* 大于1表示放大,小于1表示缩小 
                如果只有1个参数,就代表x/y方向都进行等比缩放
                如果是两个参数就x/y方向
                */
                /* 通常使用x/y */
                transform: scaleY(0.5);
            }
    
            /* 旋转:rotate */
            div:nth-of-type(3):active {
                /* 设置旋转轴心
                关键字:left top right bottom center
                 */
                background-color: purple;
                transform-origin: left top;
            }
            /* 同时给div3添加多个transform属性 */
            div:nth-of-type(3):active {
                transform: translateX(700px) rotate(-90deg);
            }
    
            /* 斜切:skew */
            div:nth-of-type(4):active {
                background-color: blue;
                /* 如果这个角度为正,则往当前负方向斜切 */
                transform: skew(-30deg);
            }
        </style>
    </head>
    
    <body>
        <div>1</div>
        <div>2</div>
        <div>3</div>
        <div>4</div>
    </body>
    
    </html>
  • 相关阅读:
    i5ting_doc的安装和使用
    vscode—修改默认的shell
    cookie的相关知识
    这是一段有毒的js代码,求大神解释!!!
    BFC的触发条件
    替换元素与非替换元素
    css中em的使用方法
    误操作导致ps界面中的工具栏消失
    导航栏里面的li标签和a标签的配合使用
    记录一下 elmentui 循环复选框不能选中问题
  • 原文地址:https://www.cnblogs.com/qiuyehaha/p/13305392.html
Copyright © 2011-2022 走看看