【发布时间】:2018-02-01 11:55:07
【问题描述】:
我正在尝试创建一个带有水平文本的新闻自动收报器,该文本连续滚动而不会在循环之间中断。理想情况下,解决方案将是纯 css/html,但我不知道这是否可能。到目前为止,这是我的初步尝试:http://jsfiddle.net/lgants/ncgsrnza/。请注意,小提琴在每个循环之间包含不需要的中断。
<p class="marquee"><span>This is text - This is text - This is text - This is text - This is text - This is text - This is text - This is text - This is text - This is text - This is text - This is text</span></p>
.marquee {
margin: 0 auto;
white-space: nowrap;
overflow: hidden;
}
.marquee span {
display: inline-block;
padding-left: 100%;
animation: marquee 5s linear infinite;
}
【问题讨论】:
-
嗯...是否可以复制文本?否则我想克隆文本层几次就需要一点 JS
-
@lumio 重复文本是什么意思?我将使用 React,因此重用组件非常容易。
-
让我试着解释一下... :) 给我几分钟
-
只需阅读其他答案 - 除了短文本问题之外,它应该可以正常工作