美文网首页
前端元素旋转和动画

前端元素旋转和动画

作者: _Clown_ | 来源:发表于2018-10-25 20:09 被阅读0次
原图
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style type="text/css">
        .box{
            width: 200px;
            height: 200px;
            background-color: gold;
            margin: 50px auto 0;
            transition: all 1s ease;
        }
        .box:hover{
            transform: translate(50px,50px);/*位移*/
        }
        .box:hover{
            transform: rotate(360deg);/*旋转*/
        }
        .box3:hover{
            transform: scale(0.5,0.2);/*缩放*/
        }
        .box4:hover{
            transform: skew(0,45deg);/*斜切*/
        }
    </style>
</head>
<body>
    <div class="box"></div>
</body>
</html>
运转后
原图
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>人物</title>
    <style type="text/css">
        .box{
            width: 120px;
            height: 182px;
            border: 1px solid #000;
            margin: 50px auto 0;
            overflow: hidden;
            position: relative;
        }
        .box img{
            position: absolute;
            left: 0;
            top: 0;
            animation: walking 1s steps(8) infinite;
        }
        @keyframes walking{
            from{
                left: 0px;
            }
            to{
                left: -960px;
            }
        }   

    </style>
</head>
<body>
    <div class="box">
        <img src="img/walking.png" alt="人物走路">
    </div>
</body>
</html>
运转后

相关文章

网友评论

      本文标题:前端元素旋转和动画

      本文链接:https://www.haomeiwen.com/subject/amnctqtx.html