当前位置:网站首页>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>
边栏推荐
- Database SQL statement summary, continuous update
- I Build a simple microservice project
- Distributed system: what, why, how
- Cesiumjs 2022^ source code interpretation [0] - article directory and source code engineering structure
- Two commonly used graphics can easily realize data display
- Epidemic strikes -- Thinking about telecommuting | community essay solicitation
- 2020 Bioinformatics | TransformerCPI
- Select sorting and bubble sorting template
- My opinion on how to effectively telecommute | community essay solicitation
- 02 ls 命令的具体实现
猜你喜欢
Sales management system of lightweight enterprises based on PHP
Flink学习6:编程模型
1289_ Implementation analysis of vtask suspend() interface in FreeRTOS
Graduation project: design seckill e-commerce system
[paddleseg source code reading] paddleseg custom data class
mysql数据库的存储
How to telecommute more efficiently | community essay solicitation
Detailed explanation of PPTC self recovery fuse
函数计算异步任务能力介绍 - 任务触发去重
ctf-pikachu-XSS
随机推荐
hbuildx中夜神模拟器的配置以及热更新
Smart subway | cloud computing injects wisdom into urban subway transportation
C语言双向链表初版
Flink学习8:数据的一致性
Katalon framework tests web (XXI) to obtain element attribute assertions
2021 RSC | Drug–target affinity prediction using graph neural network and contact maps
I was tortured by my colleague's null pointer for a long time, and finally learned how to deal with null pointer
LevelDB源码解读-SkipList
10 reasons for not choosing to use free virtual hosts
VIM mapping command
支持首次触发的 Go Ticker
How to telecommute more efficiently | community essay solicitation
【读书会第十三期】多媒体处理工具 FFmpeg 工具集
leetcode刷题:二叉树08(N叉树的最大深度)
[Yugong series] go teaching course 002 go language environment installation in July 2022
毕业设计:设计秒杀电商系统
程序员远程办公喜忧参半| 社区征文
CesiumJS 2022^ 源码解读[0] - 文章目录与源码工程结构
Parameterization of controls in katalon
Select sorting and bubble sorting template