I was using the answers on this post to make mine, and ended up with a different version making use of flexbox.
You need at least 2 text nodes and they must have equal length in order for them to have the same width, otherwise they will move at a different pace. You could instead specify a width for the .marquee, but there would likely be irregular gaps between texts.
/* Core functionality */
#animated-text-strip{
display: flex;
flex-flow: row nowrap;
align-items: center;
overflow: hidden;
}
#animated-text-strip .marquee {
white-space: nowrap;
animation: marquee 5s linear infinite;
max-width: none;
}
@keyframes marquee {
0% {
transform: translate(0, 0);
}
100% {
transform: translate(-100%, 0);
}
}
/* Styles for the sake of the demonstration */
#animated-text-strip{
background:black;
padding: 1rem 0;
}
.marquee{
font-family: 'Open Sans', sans-serif;
font-size: 2rem;
font-weight: 900;
text-transform: uppercase;
color: white;
}
<div id="animated-text-strip">
<span class="marquee">Text length has to be equal </span>
<span class="marquee">Text length has to be equal </span>
<span class="marquee">Text length has to be equal </span>
</div>
How many nodes you need will depend on the length of your text. There must always be one node more than the nodes it takes to fill the container width. So if your node takes 50% of the width, you will need 2 to fill the width, and then an extra one that will exist outside the container boundaries and will appear in screen during the animation.
Notice that max-width needs to be set to none. Otherwise if the text is longer than the container width the nodes will overlap.