开发者社区> 问答> 正文

火狐浏览器中给元素添加动画,执行完毕后,清除动画,再次添加无效,在chrome下正常 - 服务报错

"<pre class=""brush:html; toolbar: true; auto-links: false;""><!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <link rel="stylesheet" href="../css/animate.css"> <style> @-webkit-keyframes shake { from, to { -webkit-transform: translate3d(0, 0, 0); transform: translate3d(0, 0, 0); }

        10%, 30%, 50%, 70%, 90% {
            -webkit-transform: translate3d(-10px, 0, 0);
            transform: translate3d(-10px, 0, 0);
        }

        20%, 40%, 60%, 80% {
            -webkit-transform: translate3d(10px, 0, 0);
            transform: translate3d(10px, 0, 0);
        }
    }
    @-moz-keyframes shake {
        from, to {
            -webkit-transform: translate3d(0, 0, 0);
            transform: translate3d(0, 0, 0);
        }

        10%, 30%, 50%, 70%, 90% {
            -webkit-transform: translate3d(-10px, 0, 0);
            transform: translate3d(-10px, 0, 0);
        }

        20%, 40%, 60%, 80% {
            -webkit-transform: translate3d(10px, 0, 0);
            transform: translate3d(10px, 0, 0);
        }
    }
    @keyframes shake {
        from, to {
            -webkit-transform: translate3d(0, 0, 0);
            transform: translate3d(0, 0, 0);
        }

        10%, 30%, 50%, 70%, 90% {
            -webkit-transform: translate3d(-10px, 0, 0);
            transform: translate3d(-10px, 0, 0);
        }

        20%, 40%, 60%, 80% {
            -webkit-transform: translate3d(10px, 0, 0);
            transform: translate3d(10px, 0, 0);
        }
    }

    .shake {
        -webkit-animation-name: shake;
        -moz-animation: shake;
        animation-name: shake;
    }
    .animated {
        -webkit-animation-duration: 1s;
        -moz-animation-duration: 1s;
        animation-duration: 1s;
        -webkit-animation-fill-mode: both;
        -moz-animation-fill-mode: both;
        animation-fill-mode: both;
    }
    #test{
        width: 200px;
        height: 100px;
        background: #000000;
    }
</style>

</head> <body> <div id="test" class="shake animated">

</div>
<button id="add">add animation</button>
<script src="../plugins/jquery/jquery-core.src.js"></script>
<script>
    $("#add").click(function(){
        $("#test").css({
            'animation':'none',
            '-webkit-animation':'none',
            '-moz-animation':'none',
            '-o-animation':'none',
        })
    setTimeout(function(){
            $("#test").css({
                'animation':'1s 0s  both shake',
                '-webkit-animation':'1s 0s both shake ',
                '-moz-animation':'1s 0s both shake',
                '-o-animation':'1s 0s  both shake ',
            });
            console.log(0);
    },16.7)
    });
</script>

</body> </html>



"

展开
收起
montos 2020-05-31 18:55:56 713 0
1 条回答
写回答
取消 提交回答
  • Firefox版本48.0 jQuery版本1.12.4 测试正常

    2020-05-31 18:57:49
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
WEB浏览器中即将发生的安全变化 立即下载
基于浏览器的实时构建探索之路 立即下载
基于浏览器的实时构建探索之路--玄寂 立即下载