I want to make the full width auto scroll bar website component to display the text and icon, please help me to write the code in HTML, CSS and javascript. The scroll bar will auto scroll from right to left and rescroll from beginning automatically at the end. I can customise the speed of scroll. The scroll bar can place in anywhere and allow to place more than on in page without any conflicts. For styling, please add the prefix new-horizontal-scroll-bar to any class and id.
Assistant
Certainly! Below is a complete example of a reusable full-width auto-scrolling horizontal bar component that scrolls text and icons smoothly from right to left and loops continuously. You can place multiple instances anywhere on your page without conflicts and customize the scroll speed easily.
Features:
Full width auto horizontal scroll bar.
Scrolls from right to left continuously and loops.
Easy speed customization via data-scroll-speed attribute (pixels per second).
Supports multiple instances on the same page.
All classes and ids prefixed with new-horizontal-scroll-bar for styling and uniqueness.
Flexible content inside: text and icons (use any inline HTML inside).
Pauses on hover (optional: you can enable/disable).
Code:
HTML
html
<!-- Example usage of the horizontal scroll bar -->
<div class="new-horizontal-scroll-bar-container" data-scroll-speed="100">
<div class="new-horizontal-scroll-bar-content">
<span>🚀 Launching new features! </span>
<span>🔥 Hot deals all week! </span>
<span>📢 Subscribe now! </span>
<span>⭐️ Rated #1 in customer service! </span>
</div>
</div>
<!-- Multiple instances example -->
<div class="new-horizontal-scroll-bar-container" data-scroll-speed="50" style="margin-top:30px;">
<div class="new-horizontal-scroll-bar-content">
<span>🎉 Welcome to our website! </span>
<span>💡 Tips & Tricks every day </span>
<span>📩 Join our newsletter! </span>
</div>
</div>