lga*_*nts 8 html css html5 css3
我正在尝试创建一个带有水平文本的新闻自动收录器,它可以连续滚动而不会在循环之间中断.理想情况下,解决方案将是纯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;
}
Run Code Online (Sandbox Code Playgroud)
brc*_*-dd 23
这与上面的答案类似。我是从Next.js的官方网站上摘下来的。他们将其与 SVG 结合使用来制作一个滑块,以显示哪些受欢迎的公司正在使用他们的框架。
.wrapper {
max-width: 100%;
overflow: hidden;
}
.marquee {
white-space: nowrap;
overflow: hidden;
display: inline-block;
animation: marquee 10s linear infinite;
}
.marquee p {
display: inline-block;
}
@keyframes marquee {
0% {
transform: translate3d(0, 0, 0);
}
100% {
transform: translate3d(-50%, 0, 0);
}
}Run Code Online (Sandbox Code Playgroud)
<div class="wrapper">
<div class="marquee">
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce volutpat, ante eu bibendum tincidunt, sem lacus vehicula augue, ut suscipit.
</p>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce volutpat, ante eu bibendum tincidunt, sem lacus vehicula augue, ut suscipit.
</p>
</div>
</div>Run Code Online (Sandbox Code Playgroud)
小智 16
您可以尝试使用两个marquees并将其中一个设置为2.5s的延迟动画,这是完整动画(5s)的一半时间.
.marquee {
margin: 0 auto;
white-space: nowrap;
overflow: hidden;
position: absolute;
}
.marquee span {
display: inline-block;
padding-left: 100%;
animation: marquee 5s linear infinite;
}
.marquee2 span {
animation-delay: 2.5s;
}
@keyframes marquee {
0% {
transform: translate(0, 0);
}
100% {
transform: translate(-100%, 0);
}
}Run Code Online (Sandbox Code Playgroud)
<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>
<p class="marquee marquee2">
<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>Run Code Online (Sandbox Code Playgroud)