1 2 3 4

animation动画案例

最近一直苦恼做一个banner的进度条,原先用js改变width值,但明显卡顿。后来用了animation,超级好用。

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<style>
    .rotation {
        animation: rotation 8s linear;
        width: 50px;
        background:red;
        height:2px;
    }

    @keyframes rotation {
        0% {
            transform: translateX(0) ;
        }
        100% {
            transform: translateX(50px) ;
        }
    }
</style>
<body>
<div class="rotation">
    
</div>
</body>

</html>

 

posted @ 2019-02-28 14:11  红鲤鱼与LV  阅读(421)  评论(0编辑  收藏  举报