You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何解决烟雾动画视频播放完毕后右下角残留痕迹问题

问题描述

烟雾动画播放完毕后,右下角会残留少许痕迹,需要消除该问题并修复。问题情况如下:
问题截图

使用的烟雾视频文件为smoke.mp4,相关代码片段如下:

CSS代码

body 
  {
  margin: 0;
  padding: 0;
  background:black;
  }

section {
  height: 100vh;
  background: #000;
}

video {
  object-fit: cover;
}

h1 {
  margin: 0;
  padding: 0;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 100%;
  text-align: center;
  color: #ddd;
  font-size: 5em;
  font-family: sans-serif;
  letter-spacing: 0.2em;
}

h1 span {
  display: inline-block;
  animation: animate 1s linear forwards;
}

@keyframes animate {
  0% {
    opacity: 0;
    transform: rotateY(90deg);
    filter: blur(10px);
  }
  100% {
    opacity: 1;
    transform: rotateY(0deg);
    filter: blur(0px);
  }
}

h1 span:nth-child(1) {
  animation-delay: 1s;
}

h1 span:nth-child(2) {
  animation-delay: 1.5s;
}

h1 span:nth-child(3) {
  animation-delay: 2s;
}

h1 span:nth-child(4) {
  animation-delay: 2.5s;
}

h1 span:nth-child(5) {
  animation-delay: 3s;
}

h1 span:nth-child(6) {
  animation-delay: 3.75s;
}

h1 span:nth-child(7) {
  animation-delay: 4s;
}

h1 span:nth-child(8) {
  animation-delay: 4.5s;
}

HTML代码

<section>
       <video src="smoke.mp4" autoplay muted></video>

  <h1>
    <span>W</span>
    <span>E</span>
    <span>L</span>
    <span>C</span>
    <span>O</span>
    <span>M</span>
    <span>E</span>
  </h1>
</section>
解决方案

残留痕迹是因为视频播放结束后停留在带痕迹的最后一帧,或视频边缘超出容器范围,可通过以下方式解决:

  • 隐藏播放完毕的视频:用JavaScript监听视频结束事件,播放完成后隐藏视频元素

    document.querySelector('video').addEventListener('ended', function() {
      this.style.display = 'none';
    });
    

    将这段代码放在HTML的</body>标签前即可。

  • 修改视频最后一帧:用视频编辑工具把smoke.mp4的最后一帧替换为纯黑色帧,从根源消除痕迹。

  • 裁剪视频溢出部分:给section添加溢出隐藏属性,确保视频超出容器的部分被裁剪

    section {
      height: 100vh;
      background: #000;
      overflow: hidden; /* 新增 */
    }
    

内容的提问来源于stack exchange,提问作者user14178341

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.09 19:25:29