我正在寻找marquee标签替代品,并发现如何通过CSS进行.但是我使用的消息长度可变,所以可以选择将'45s'属性设置为100%,这样无论消息有多长或多短,消息都会显示所有消息和循环消息显示后再次显示?
.marquee {
margin: 0 auto;
white-space: nowrap;
overflow: hidden;
position: absolute;
color: #ffffff;
background-color: #000000;
font-family: Arial Rounded MT Bold;
}
.marquee span {
display: inline-block;
padding-left: 100%; /* show the marquee just outside the paragraph */
animation: marquee 45s linear infinite;
}
@keyframes marquee {
from { text-indent: 0%}
to { text-indent: -150% }
}Run Code Online (Sandbox Code Playgroud)
<p id="PassengerNews_Scrollbar" class="microsoft marquee" style="height: 95%; width: 90%;left: 5%;top: 2%;font-size: 7%;">
<span>|*NewsData*|</span>
</p>Run Code Online (Sandbox Code Playgroud)