wingsac 2021-08-09 21:26 采纳率: 100%
浏览 44
已结题

怎么解决C3图片播放完重新播放会卡的问题

img

img


<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    body {
        background: beige;
    }
    
    div.m {
        position: relative;
        width: 1920px;
        height: 336px;
        background: url(./image/bg1.png) no-repeat;
        animation: M 3S linear infinite;
        background-attachment: fixed;
    }
    
    div.b {
        position: absolute;
        top: 50%;
        width: 200px;
        height: 100px;
        background: url(./image/bear.png) no-repeat;
        /* 元素添加多个动画  用逗号隔开 */
        animation: bear .5s steps(8) infinite, move 3s linear forwards;
    }
    
    @keyframes bear {
        0% {
            background-position: 0 0;
        }
        100% {
            background-position: -1600px 0;
        }
    }
    
    @keyframes move {
        0% {
            left: 0;
        }
        70% {
            left: 25%;
        }
        100% {
            left: 50%;
            /* margin-left: -100px; */
            transform: translateX(-50%);
        }
    }
    
    @keyframes M {
        0% {
            background-position: 0 0;
        }
        25% {
            background-position: 25% 0;
        }
        50% {
            background-position: 50% 0;
        }
        100% {
            background-position: 100% 0;
        }
    }
</style>

<body>
    <div class="m">
        <div class="b"></div>
    </div>

</body>

</html>
  • 写回答

2条回答 默认 最新

  • 关注

    背景图片bg1.png需要设置 repeat-x横向重复;
    背景图片动画 background-position的x位置要从 0 到 -3840px (3840是背景图片实际宽度), 不是100%。
    代码如下:(如有帮助,望采纳!谢谢! 点击我这个回答右上方的【采纳】按钮)

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Document</title>
    </head>
    <style>
        body {
            background: beige;
        }
        div.m {
            position: relative;
            width: 1920px;
            height: 336px;
            background: url(./image/bg1.png) repeat-x;
            animation: M 5S linear infinite;
            background-attachment: fixed;
        }
        div.b {
            position: absolute;
            top: 50%;
            width: 200px;
            height: 100px;
            background: url(./image/bear.png) no-repeat;
            /* 元素添加多个动画  用逗号隔开 */
            animation: bear .5s steps(8) infinite, move 3s linear forwards;
        }
        @keyframes bear {
            0% {
                background-position: 0 0;
            }
            100% {
                background-position: -1600px 0;
            }
        }
        @keyframes move {
            0% {
                left: 0;
            }
            70% {
                left: 25%;
            }
            100% {
                left: 50%;
                /* margin-left: -100px; */
                transform: translateX(-50%);
            }
        }
        @keyframes M {
            0% {
                background-position: 0 0;
            }
            100% {
                background-position: -3840px 0;
            }
        }
    </style>
    <body>
        <div class="m">
            <div class="b"></div>
        </div>
    </body>
    </html>
    
    
    
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

问题事件

  • 系统已结题 8月18日
  • 已采纳回答 8月10日
  • 创建了问题 8月9日

悬赏问题

  • ¥15 IAR程序莫名变量多重定义
  • ¥15 (标签-UDP|关键词-client)
  • ¥15 关于库卡officelite无法与虚拟机通讯的问题
  • ¥100 已有python代码,要求做成可执行程序,程序设计内容不多
  • ¥15 目标检测项目无法读取视频
  • ¥15 GEO datasets中基因芯片数据仅仅提供了normalized signal如何进行差异分析
  • ¥100 求采集电商背景音乐的方法
  • ¥15 数学建模竞赛求指导帮助
  • ¥15 STM32控制MAX7219问题求解答
  • ¥20 在本地部署CHATRWKV时遇到了AttributeError: 'str' object has no attribute 'requires_grad'