开发者社区> 问答> 正文

如何用jquery控制div依次执行动画

<!DOCTYPE html>
<html>
<head>
    <title>demo</title>
</head>
<style>
    *{
        padding: 0;
        margin: 0;
    }
    body{
        width: 100%;
        height: 100%;
        background: #f5f5f5;
    }
    #container{
        width: 960px;
        margin: 10em auto;
    }
    #container .content{
        width: 25%;
        height: 200px;
        float: left;
        text-align: center;
        padding:10px;
        margin: 10px;
        background: #abcdef;
        border: 1px solid #000;
        -webkit-animation-name: card-in;
        -webkit-animation-duration: .5s;
        animation-name: card-in;
        animation-duration: .5s;
    }
    @-webkit-keyframes card-in {
        from {
            opacity: 0;
            -webkit-transform: scale(1.3);
            transform: scale(1.3);
        }
        to {
            opacity: 1;
            -webkit-transform: scale(1);
            transform: scale(1);
        }
    }
    @keyframes card-in {
        from {
            opacity: 0;
            -webkit-transform: scale(1.3);
            transform: scale(1.3);
        }
        to {
            opacity: 1;
            -webkit-transform: scale(1);
            transform: scale(1);
        }
    }
</style>
<body>
    <div id="container">
        <div class="content">123465798</div>
        <div class="content">123465798</div>
        <div class="content">123465798</div>
        <div class="content">123465798</div>
        <div class="content">123465798</div>
        <div class="content">123465798</div>
        <div class="content">123465798</div>
        <div class="content">123465798</div>
        <div class="content">123465798</div>
    </div>
 
</body>
</html>

展开
收起
a123456678 2016-07-13 15:31:11 2303 0
1 条回答
写回答
取消 提交回答
  • #container .content{
            width: 25%;
            height: 200px;
            float: left;
            text-align: center;
            padding:10px;
            margin: 10px;
            background: #abcdef;
            border: 1px solid #000;
        }
    #container .content.start{
            -webkit-animation-name: card-in;
            -webkit-animation-duration: .5s;
            animation-name: card-in;
            animation-duration: .5s;
    }
    
    $(function(){
        var $content = $('.content');
        for (var i = 0; i < $content.length; i++) {
            (function($this,i){
                setTimeout(function(){
                    $this.addClass('start');
                },i*100)
            })($($content[i]),i)
        };
    })
    2019-07-17 19:55:42
    赞同 展开评论 打赏
问答分类:
问答地址:
问答排行榜
最热
最新

相关课程

更多

相关电子书

更多
JS 语言在引擎级别的执行过程 立即下载
低代码开发师(初级)实战教程 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载