字幕不平滑滚动,需要100%平滑滚动字幕

  • 本文关键字:字幕 平滑 滚动 100% 需要 html
  • 更新时间 :
  • 英文 :


我正在使用从右侧到左侧的字幕滚动。下面的代码运行良好。但它的滚动并不流畅。内容"悬停在我身上停止"正在闪烁。我需要一个100%平滑滚动下面的字幕。请帮帮我。没有javascript是否可能??

<marquee behavior='scroll' direction='left' scrollamount='3' onmouseover='this.stop()' onmouseout='this.start()'>Hover on me to stop</marquee>

如果你想尝试使用纯CSS,那么这是最简单的方法。尽管您需要检查对旧浏览器的支持,并添加供应商前缀。

.marquee-parent {
  position: relative;
  width: 100%;
  overflow: hidden;
  height: 30px;
}
.marquee-child {
  display: block;
  width: 147px;
  /* width of your text div */
  height: 30px;
  /* height of your text div */
  position: absolute;
  animation: marquee 5s linear infinite; /* change 5s value to your desired speed */
}
.marquee-child:hover {
  animation-play-state: paused;
  cursor: pointer;
}
@keyframes marquee {
  0% {
    left: 100%;
  }
  100% {
    left: -147px /* same as your text width */
  }
}
<div class="marquee-parent">
  <div class="marquee-child">
    Hover on me to stop
  </div>
</div>

派对迟到了一点。。

这有一个角度指令:https://github.com/davidtran/angular-marquee.你不接触任何js-只需添加指令标签,你就完成了

<div angular-marquee></div>

它并没有回到"不推荐使用的标签"的论点,依赖于现代解决方案