css3使用animation动画实现无限滚动轮播图

简单效果图
请添加图片描述
简单功能描述:
使用css3的animation使用轮播图无限滚动动画效果

css

 <style>
        * {
            margin: 0;
            padding: 0;
        }

        ul {
           list-style: none;
            width: 100%;
        }
        li {
            list-style-type: none;
        }

        .box {
            width: 1000px;
            height: 100%;
            overflow: hidden;
            margin: 0 auto;
        }

        .box1-ul,.box2-ul {
           display: flex;
           flex-wrap: nowrap;
        }

        .box1-ul {
            width: 6000px;
            animation: myAnimation 16s infinite 3s;
        }

        .box1-ul:hover {
            /* 鼠标移入暂停 */
            animation-play-state: paused;
        }

        .box2-ul { 
            width: 3000px;
            /* myAnimation2动画针 10s执行完一轮 infinite无限循环 3代表执行三次动画 延迟3s执行  alternate执行完回退执行*/
            animation: myAnimation2 10s 3 2s alternate;
        }

        .box2-ul:hover {
            /* 鼠标移入暂停 paused 默认是运动 running值 */
            animation-play-state: paused;
           
        }

        .box1-ul li,.box2-ul li {
            flex-shrink: 0;
            width: 1000px;
            height: 400px;
            font-size: 50px;
            text-align: center;
            line-height: 400px;
            font-weight: 800;
            color: red;
        }

        .box1-ul li:nth-child(odd),.box2-ul li:nth-child(odd) {
            background-image: linear-gradient(blue 20%, yellow 30%);
        }

        .box1-ul li:nth-child(even),.box2-ul li:nth-child(even)  {
            background-image: linear-gradient(rgb(255, 85, 0) 20%, yellow 30%);
        }

        @keyframes myAnimation {
            20% {
                transform: translateX(-1000px);
            }

            40% {
                transform: translateX(-2000px);
            }

            60% {
                transform: translateX(-3000px);
            }

            80% {
                transform: translateX(-4000px);
            }

            100% {
                transform: translateX(-5000px);
            }

        }

        @keyframes myAnimation2 {
            50% {
                margin-left: -1000px;
            }

            100% {
                margin-left: -2000px;
            }
        }

    </style>

html

<div class="box">
        <ul class="box1-ul">
            <li>1</li>
            <li>2</li>
            <li>3</li>
            <li>4</li>
            <li>5</li>
            <li>6</li>
        </ul>


        <ul class="box2-ul">
            <li>A</li>
            <li>B</li>
            <li>C</li>
        </ul>
    </div>
  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

追逐梦想之路_随笔

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值