实现banner效果

纯css实现轮播图banner自动轮换效果

编程开发 2020-10-19 03:33:13 27

导读

话不多说直接上代码* { margin: 0; padding: 0; ……

话不多说 直接上代码

* {
            margin: 0;
            padding: 0;
        }

        .container {
            margin:300px auto;
            height: 400px;
            width: 1146px;
            overflow: hidden;
        }

        /* .wrap */
        .wrap {
            position: relative;
            width:10000px;
            left: 0px;
            animation: animateImg ease 5s infinite normal;
        }

        /* 图片大小 */
        .wrap img {
            width: 1146px;
            float: left;
            height: 400px;
            display: block;
        }

        /* 动画 */
        @keyframes animateImg {
            0% {
                left: 0px;
            }

            20% {
                left: -0px;
            }

            40% {
                left: -1146px;
            }

            60% {
                left: -2292px;
            }

            80% {
                left: -3438px;
            }

            100% {
                left: 0px;
            }
        }

动画效果像素根据自己图片大小修改

<div class="container">
        <div class="wrap">
            <img src="images/banner1.jpg"alt="" />
            <img src="images/banner2.jpg"alt="" />
            <img src="images/banner3.jpg"alt="" />
            <img src="images/banner4.jpg"alt="" />
        </div>


1253067 TFnetwork_cn