My CSS marquee effect is working perfectly, but I am having trouble with the speed. The issue arises when the text length varies - shorter text takes longer to scroll while longer text scrolls quickly. This inconsistency is due to the animation duration
animation: marquee 15s linear infinite;
I am looking for a solution to run the marquee at a consistent speed regardless of the text length. If necessary, I am willing to explore using Javascript (although my attempts so far have not been successful).
Below is my current CSS code:
<style>
/* Make it a marquee */
.marquee {
width: 100%;
margin: 0 auto;
white-space: nowrap;
overflow: hidden;
background-color: #000000;
bottom: 0px;
color: white;
}
.marquee span {
display: inline-block;
padding-left: 100%;
text-indent: 0;
animation: marquee 15s linear infinite;
animation-delay: 10s;
background-color: #000000;
color: white;
bottom: 0px;
}
/* Make it move */
@keyframes marquee {
0% {
transform: translate(10%, 0);
}
100% {
transform: translate(-100%, 0);
}
}
/* Make it pretty */
.scroll {
padding-left: 1.5em;
position: fixed;
font: 50px 'Verdana';
bottom: 0px;
color: white;
left: 0px;
height: 10%;
}
</style>
HTML
<div class="marquee">
<p class="scroll marquee"><span id="scrolltext"></span></p>
</div>