CSS3选框效果,没有空的空间

Lol*_*ums 5 html css marquee css3

这个问题有一个答案,它在选取框的每次迭代结束时留下了很多空白空间:CSS3 Marquee Effect

有没有办法<marquee></marquee>用CSS3 实现平滑效果,不会留下这个空间?

我有很多小元素,看起来有点像SO的蓝色标签,专门填充选框的内容,而不是一个连续的主体或文本墙.

LGS*_*Son 13

下面是一个示例,您可以通过设置延迟和持续时间来控制文本之间的空间

.marquee {
  background-color: #ddd;
  width: 500px;
  margin: 0 auto;
  overflow: hidden;
  white-space: nowrap;
}
.marquee span {
  display: inline-block;
  font-size: 20px;
  position: relative;
  left: 100%;
  animation: marquee 8s linear infinite;
}
.marquee:hover span {
  animation-play-state: paused;
}

.marquee span:nth-child(1) {
  animation-delay: 0s;
}
.marquee span:nth-child(2) {
  animation-delay: 0.8s;
}
.marquee span:nth-child(3) {
  animation-delay: 1.6s;
}
.marquee span:nth-child(4) {
  animation-delay: 2.4s;
}
.marquee span:nth-child(5) {
  animation-delay: 3.2s;
}

@keyframes marquee {
  0%   { left: 100%; }
  100% { left: -100%; }
}
Run Code Online (Sandbox Code Playgroud)
<p class="marquee">
  <span>this is a</span>
  <span>simple marquee</span>
  <span>using css</span>
  <span>only tech</span>
  <span>with a delay</span>
</p>
Run Code Online (Sandbox Code Playgroud)

  • @saleemahmed不确定我是否理解.此动画从页面加载开始.如果你想开始使用load事件,只需将`animation:marquee 8s linear infinite;`移动到它自己的类,并在事件处理程序中,将该类添加到`marquee`元素. (2认同)