<style>
    *{
        margin:0;
        padding:0;
        /* box-sizing: border-box; */
    }
    ul{
        list-style: none;
    }
    #nav{
        width:900px;
        height:100px;
        border:2px solid rgb(70, 69, 69);
        margin:100px auto;   
        overflow: hidden;
    }
    #nav ul{
        animation:moving 5s linear infinite;
        width:200%; /*怎么模拟动画无线滚动,关键点在这,因为当动画滚动完之后,ul会回到起始位置,如果设置宽度为大盒子的2倍则在视觉上不会出现回到初始位置重新滚动问题*/
    }
    #nav ul li{
        float:left; 
    }
    #nav ul li img{ 
        width:100px;
        height: 100px;
    }
    /* 自定义动画 */
        @keyframes moving{
        from{
            transform:translateX(0)
        }
        to{
            transform: translateX(-900px);
        }

        }
        #nav:hover ul{ /*鼠标移入正在运行动画停止*/
        animation-play-state:paused ;
        }
</style>
<div id="nav">
        <ul>
            <!-- 将图片复制两份,保证每份图片的宽跟 nav盒子宽度相同 -->
            <!-- 第一份 -->
            <li><img src="https://img0.baidu.com/it/u=1032314795,3433105171&amp;fm=253&amp;fmt=auto&amp;app=138&amp;f=JPEG?w=889&amp;h=500" alt=""></li>
            <li><img src="https://img0.baidu.com/it/u=1032314795,3433105171&amp;fm=253&amp;fmt=auto&amp;app=138&amp;f=JPEG?w=889&amp;h=500" alt=""></li>
            <li><img src="https://img0.baidu.com/it/u=1032314795,3433105171&amp;fm=253&amp;fmt=auto&amp;app=138&f=JPEG?w=889&h=500" alt=""></li>
            <li><img src="https://img0.baidu.com/it/u=1032314795,3433105171&fm=253&fmt=auto&app=138&f=JPEG?w=889&h=500" alt=""></li>
            <li><img src="https://img0.baidu.com/it/u=1032314795,3433105171&fm=253&fmt=auto&app=138&f=JPEG?w=889&h=500" alt=""></li>
            <li><img src="https://img0.baidu.com/it/u=1032314795,3433105171&fm=253&fmt=auto&app=138&f=JPEG?w=889&h=500" alt=""></li>
            <li><img src="https://img0.baidu.com/it/u=1032314795,3433105171&fm=253&fmt=auto&app=138&f=JPEG?w=889&h=500" alt=""></li>
            <li><img src="https://img0.baidu.com/it/u=1032314795,3433105171&fm=253&fmt=auto&app=138&f=JPEG?w=889&h=500" alt=""></li>
            <li><img src="https://img0.baidu.com/it/u=1032314795,3433105171&fm=253&fmt=auto&app=138&f=JPEG?w=889&h=500" alt=""></li>
            <!-- 第二份 -->
            <li><img src="https://img0.baidu.com/it/u=1032314795,3433105171&fm=253&fmt=auto&app=138&f=JPEG?w=889&h=500" alt=""></li>
            <li><img src="https://img0.baidu.com/it/u=1032314795,3433105171&fm=253&fmt=auto&app=138&f=JPEG?w=889&h=500" alt=""></li>
            <li><img src="https://img0.baidu.com/it/u=1032314795,3433105171&fm=253&fmt=auto&app=138&f=JPEG?w=889&h=500" alt=""></li>
            <li><img src="https://img0.baidu.com/it/u=1032314795,3433105171&fm=253&fmt=auto&app=138&f=JPEG?w=889&h=500" alt=""></li>
            <li><img src="https://img0.baidu.com/it/u=1032314795,3433105171&fm=253&fmt=auto&app=138&f=JPEG?w=889&h=500" alt=""></li>
            <li><img src="https://img0.baidu.com/it/u=1032314795,3433105171&fm=253&fmt=auto&app=138&f=JPEG?w=889&h=500" alt=""></li>
            <li><img src="https://img0.baidu.com/it/u=1032314795,3433105171&fm=253&fmt=auto&app=138&f=JPEG?w=889&h=500" alt=""></li>
            <li><img src="https://img0.baidu.com/it/u=1032314795,3433105171&fm=253&fmt=auto&app=138&f=JPEG?w=889&h=500" alt=""></li>
            <li><img src="https://img0.baidu.com/it/u=1032314795,3433105171&fm=253&fmt=auto&app=138&f=JPEG?w=889&h=500" alt=""></li>
        </ul>
    </div>

原文地址:https://blog.csdn.net/qq_41429765/article/details/134707087

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任

如若转载,请注明出处:http://www.7code.cn/show_18735.html

如若内容造成侵权/违法违规/事实不符,请联系代码007邮箱suwngjj01@126.com进行投诉反馈,一经查实,立即删除

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注