JSFiddle - React, Tailwind, and code Playground
by AJIEKCEU
HTML
<div class="marquee"><span>Привет, мир! Привет, мир! Привет, мир! Привет, мир! Привет, мир!</span></div>
CSS
.marquee {
width: 450px;
margin: 0 auto;
white-space: nowrap;
overflow: hidden;
box-sizing: border-box;
border: 1px dotted #800000;
}
.marquee span {
display: inline-block;
padding-left: 100%;
animation: marquee 15s linear infinite;
}
.marquee span:hover {
animation-play-state: paused
}
@keyframes marquee {
0% { transform: translate(0, 0); }
100% { transform: translate(-100%, 0); }
}
JavaScript
function animate(id) {
var node = document.getElementById(id).childNodes[0];
var text = node.data;
setInterval(function () {
text = text.substring(1) + text[0];
node.data = text;
}, 125); //интервал прокрутки, мс
}
window.addEventListener('load', function (e) { animate('marqueeline'); }, false);