使用Jquery配合CSS3动画和2D变换属性制作动态特效

版权声明:版权是个什么玩意儿?看得上随便转 https://blog.csdn.net/Byte_Dance/article/details/81916615
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Title</title>
    <script src="http://code.jquery.com/jquery-latest.js"></script>

    <style>
        .di{
            width:100px;
            height: 100px;
            background: red;
            animation: myfirst 1s linear;
            animation-iteration-count:1000;
        }

        @keyframes myfirst
        {
            0%{transform: rotate(0deg);}
            100%{transform: rotate(360deg);}
        }
    </style>
</head>
<body>
    <div class="di"></div>
    <script>
        var i = true;
        $(".di").click(function(){
            console.log(i)
            if(i){
                $(this).css({"animation-play-state":"paused"})
            }else{
                $(this).css({"animation-play-state":"running"})
            }
            i = !i;
        })
    </script>
</body>
</html>

猜你喜欢

转载自blog.csdn.net/Byte_Dance/article/details/81916615
今日推荐