美文网首页
21.css3轮播效果

21.css3轮播效果

作者: jqClub | 来源:发表于2019-03-20 14:27 被阅读0次

    html:

    <div class="div_first">
        <div class="div_second">
            <div class="item">1</div>
            <div class="item">2</div>
            <div class="item">3</div>
            <div class="item">1</div>
        </div>
    </div>
    

    css:

    .div_first{
        width       : 1000px;
        height      : 80px;
        margin-top  : 100px;
        margin-left : 250px;
        overflow    : hidden;
    }
    .div_second{
        width     : 4000px;
        position  : relative;
        animation : myimg 6s ease-in-out infinite;
        font-size : 0;
    }
    .item {
        width       : 1000px;
        height      : 80px;
        text-align  : center;
        line-height : 80px;
        display     : inline-block;
        font-size   : 20px;
        border      : 1px solid;
        box-sizing  : border-box;
    
    }
    @keyframes myimg{
        /* 第一帧 */
        0%{
            left: 0;
        }
        23.3% {
            left: 0;
        }
        33.3% {
            left: -1000px;
        }
        /* 第二帧 */
        56.6%{
            left: -1000px;
        }
        66.6%{
            left: -2000px;
        }
        /* 第三帧 */
        90%{
            left: -2000px;
        }
        100%{
            left: -3000px;
        }
        /* 第四帧:第四帧不用写, 因为它已经是第一帧的内容了 */
    }
    

    查看效果

    相关文章

      网友评论

          本文标题:21.css3轮播效果

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