Flex中的字幕div

Bus*_*ter 6 javascript css scroll marquee

我正在尝试创建一个像字幕效果一样的无限水平“滚动”(例如,像这样的滚动)。

这是我的代码:

.parent {
  border: 1px solid black;
  width: 100%;
  height: 2rem;
}

.container {
  height: 100%;
  display: flex;
  padding-left: 10%;
  border: 1px solid tomato;
  animation: marquee 5s linear infinite;
}

@keyframes marquee {
  0% {
    transform: translate(0%, 0);
  }
  100% {
    transform: translate(-100%, 0);
  }
}

.child1 {
  width: 10rem;
  height: 100%;
  background-color: #84B7DF;
}
.child2 {
  width: 18rem;
  height: 100%;
  background-color: #f58db6;
}
.child3 {
  width: 13rem;
  height: 100%;
  background-color: #ffc410;
}
.child4 {
  width: 21rem;
  height: 100%;
  background-color: #C8E7C1;
}
Run Code Online (Sandbox Code Playgroud)
<div class="parent">
  <div class="container">
    <div class="child1"></div>
    <div class="child2"></div>
    <div class="child3"></div>
    <div class="child4"></div>
  </div>
</div>
Run Code Online (Sandbox Code Playgroud)

如您所见,它有效,但并不完美。我希望绿色矩形一旦移动,蓝色(略有间隔)就会立即出现,我不希望有整个白色的屏幕。

我希望我的意思是明确的...

非常感谢!