HTML uses marquee to achieve text scrolling left and right

HTML uses marquee to achieve text scrolling left and right

Copy code
The code is as follows:

<BODY>
//With the help of marquee
<MARQUEE behavior="scroll" contenteditable="true" onstart="this.firstChild.innerHTML+=this.firstChild.innerHTML;" scrollamount="3" width="100">
<SPAN unselectable="on">Here is the content to scroll</SPAN>
</MARQUEE>

//Ordinary implementation method
<DIV id="scrollobj" style="white-space:nowrap;overflow:hidden;width:500px;">
<span>Here is the content to scroll</span>
</DIV>
<script language="javascript" type="text/javascript">
function scroll(obj) {
var tmp = (obj.scrollLeft)++;
//When the scroll bar reaches the top right
if (obj.scrollLeft==tmp) obj.innerHTML += obj.innerHTML;
//When the scroll bar scrolls the width of the initial content, the scroll bar returns to the leftmost end
if (obj.scrollLeft>=obj.firstChild.offsetWidth) obj.scrollLeft=0;
}
setInterval("scroll(document.getElementById('scrollobj'))",20);
</script>
</BODY>

<<:  A practical record of an accident caused by MySQL startup

>>:  VUE render function usage and detailed explanation

Recommend

innodb_flush_method value method (example explanation)

Several typical values ​​of innodb_flush_method f...

Use of Linux tr command

1. Introduction tr is used to convert or delete a...

Design of image preview in content webpage

<br />I have written two articles before, &q...

Details of 7 kinds of component communication in Vue3

Table of contents 1. Vue3 component communication...

A brief talk about JavaScript Sandbox

Preface: Speaking of sandboxes, our minds may ref...

Summary of the minesweeping project implemented in JS

This article shares the summary of the JS mineswe...

Detailed tutorial on using cmake to compile and install mysql under linux

1. Install cmake 1. Unzip the cmake compressed pa...

MySQL 8.0 user and role management principles and usage details

This article describes MySQL 8.0 user and role ma...

CSS achieves footer "bottom absorption" effect

We often encounter this problem: how to use CSS t...

Is your website suitable for IE8?

During the Olympic Games, IE 8 Beta 2 will be rele...

How to generate PDF and download it in Vue front-end

Table of contents 1. Installation and introductio...

JavaScript to achieve window display effect

This article shares the specific code of JavaScri...

Use vertical-align to align input and img

Putting input and img on the same line, the img ta...