JSFiddle - React, Tailwind, and code Playground
HTML
<div class="scroll">This text be scrollin'!</div>
CSS
body {
overflow: hidden;
}
.scroll {
position: absolute;
white-space: nowrap;
}
JavaScript
$(document).ready(function() {
var $width = $(document).width();
var $scrollWidth = $('.scroll').outerWidth();
$('.scroll').css({'right': -$scrollWidth + 'px'});
function scroll() {
$('.scroll').animate({
right: $width
}, 8000, function() {
$('.scroll').css({'right': -$scrollWidth + 'px'});
scroll();
});
}
scroll();
});