gpt4 book ai didi

javascript - DIV 不能像 Marquee 那样正确滚动

转载 作者:行者123 更新时间:2023-12-05 02:25:47 25 4
gpt4 key购买 nike

作为<marquee>标签已贬值。我创建了一个简单的 CSS 来从右向左滚动我的 DIV。

<style>
#scroll-container {
overflow: hidden;
}

#scroll-text {
transform: translateX(100%);
animation: my-animation 15s linear infinite;
}

@keyframes my-animation {
from {
transform: translateX(100%);
}
to {
transform: translateX(-100%);
}
}
</style>


<div id="scroll-container">
<div id="scroll-text"> </div></div>


<script type="text/javascript" src="https://script.google.com/macros/s/AKfycbwrQBGLeIphnholKad8gvarUZ4wsMEiG9PlboMiuuB6lxW4l_UnjTuxouy2NRZkeSAd/exec"></script>
<script>
document.getElementById("scroll-text").innerHTML = marq1 + " " + "<b> <span style='color: #A000ff;'>" + marq2 + "</span> </b>" + " " + marq3 + " " + marq4 ;
</script>

它应该像字幕行为一样滚动,

但不是 1 行,而是滚动 3 行。

如何解决这个问题?

This is my Web Page

下面是移动设备截屏

Mobile Device Cropped Screenshot

最佳答案

试试这个,这应该可以解决问题。

<style>
#scroll-container {
overflow: hidden;
white-space: nowrap; /*add this*/
}

#scroll-text {
transform: translateX(100%);
animation: my-animation 15s linear infinite;
}

@keyframes my-animation {
from {
transform: translateX(100%);
}
to {
transform: translateX(-100%);
}
}
</style>

关于javascript - DIV 不能像 Marquee 那样正确滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/74307690/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com