当前位置:网站首页>JS realizes the effect of text scrolling marquee
JS realizes the effect of text scrolling marquee
2022-07-04 04:18:00 【Undefind_ object】
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
#scroll_div {
height: 30px;
line-height: 30px;
overflow:hidden;
white-space: nowrap;
width: 800px;
background-color: #23527c;
color: #d8d8d8;
margin: 1rem 0;
text-align: center;
}
#scroll_begin,#scroll_end {
display: inline;
}
</style>
</head>
<body>
<div id="scroll_div">
<div id="scroll_begin">
<span class="pad_right"> This is the first one ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah ah </span>
</div>
<div id="scroll_end"></div>
</div>
<script>
function ScrollImgLeft() {
var speed = 20;// Initialization speed That is, the overall scrolling speed of the font
var MyMar = null;// Initialize a variable to be empty Used to store the obtained text content
var scroll_begin = document.getElementById("scroll_begin");// Get the beginning of the scroll id
var scroll_end = document.getElementById("scroll_end");// Get the end of scrolling id
var scroll_div = document.getElementById("scroll_div");// Get the beginning of the whole id
scroll_end.innerHTML = scroll_begin.innerHTML;// Scrolling is html Internal content , Native knowledge !
// Define a method
function Marquee() {
if (scroll_end.offsetWidth - scroll_div.scrollLeft <= 0){
scroll_div.scrollLeft -= scroll_begin.offsetWidth;
} else{
scroll_div.scrollLeft++;
}
}
MyMar = setInterval(Marquee, speed);
// Slide in pause
scroll_div.onmouseover = function () {
clearInterval(MyMar);
}
// Slide out continue
scroll_div.onmouseout = function () {
MyMar = setInterval(Marquee, speed);
}
}
ScrollImgLeft();
</script>
</body>
</html>
边栏推荐
- Tcpclientdemo for TCP protocol interaction
- 2020 Bioinformatics | TransformerCPI
- Getting started with the go language is simple: go implements the Caesar password
- Flink学习7:应用程序结构
- [book club issue 13] multimedia processing tool ffmpeg tool set
- Pytest multi process / multi thread execution test case
- Evolution of MySQL database architecture
- pytest多进程/多线程执行测试用例
- Katalon framework test web (XXVI) automatic email
- 思考的小记录
猜你喜欢
还原窗口位置的微妙之处
Cesiumjs 2022^ source code interpretation [0] - article directory and source code engineering structure
Pointer array and array pointer
Infiltration practice guest account mimikatz sunflower SQL rights lifting offline decryption
My opinion on how to effectively telecommute | community essay solicitation
ctf-pikachu-XSS
How to telecommute more efficiently | community essay solicitation
ctf-pikachu-CSRF
*. No main manifest attribute in jar
Flink learning 7: application structure
随机推荐
hbuildx中夜神模拟器的配置以及热更新
ctf-pikachu-CSRF
Graduation project: design seckill e-commerce system
Spa in SDP
SQL語句加强練習(MySQL8.0為例)
Myslq delete followed by limit
I was tortured by my colleague's null pointer for a long time, and finally learned how to deal with null pointer
Restore the subtlety of window position
Go 语言入门很简单:Go 实现凯撒密码
JS实现文字滚动 跑马灯效果
三年进账35.31亿,这个江西老表要IPO了
量子力学习题
Select sorting and bubble sorting template
VIM add interval annotation correctly
Database SQL statement summary, continuous update
【读书会第十三期】视频文件的封装格式
01 qemu 启动编译好的镜像 VFS: Unable to mount root fs on unknown-block(0,0)
思考的小记录
The new data center helps speed up the construction of a digital economy with data as a key element
Two commonly used graphics can easily realize data display