Home > Article > Web Front-end > jquery implements marquee effect (horizontal and vertical scrolling of text or pictures)_jquery
Originally, in the front-end HTML code, Marquee was used to achieve horizontal and vertical scrolling of text or images. However, after considering browser compatibility and compliance with W3C standards, I later thought that it would still be implemented using JavaScript code. Later, I fell in love with jquery. I hope the content written below will be helpful to beginners. Experts are not allowed to criticize, but guidance is welcome and I am grateful.
Principle: The principle of seamless scrolling is to use two containers with the same content to achieve the effect of deceiving people's vision. Then scrolling is achieved by moving the scroll bar of the entire large container left and right or up and down. Attached below is a hand-drawn picture to briefly explain the principle. First of all, our purpose is to realize the horizontal scrolling of the content in box 1 to the left (the principles of right scrolling and up and down scrolling are actually roughly the same. As long as you know one of them, the others are not a problem.). Then when the page is loaded, we use js to dynamically assign the content in box 2 (html content) to be the same as the content in box 1. Then gradually move the scroll bar to the right to achieve the left effect. Having said so much. I'll attach the code (with comments) later.
1.html code