当前位置:网站首页>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>
边栏推荐
- 量子力学习题
- VIM mapping command
- Pytest multi process / multi thread execution test case
- Katalon framework test web (XXVI) automatic email
- '2'&gt;' 10'==true? How does JS perform implicit type conversion?
- AAAI2022 | Word Embeddings via Causal Inference: Gender Bias Reducing and Semantic Information Preserving
- leetcode刷题:二叉树09(二叉树的最小深度)
- Evolution of MySQL database architecture
- The maximum expiration time of client secret in azure ad application registration is modified to 2 years
- 拼夕夕二面:说说布隆过滤器与布谷鸟过滤器?应用场景?我懵了。。
猜你喜欢
leetcode刷题:二叉树07(二叉树的最大深度)
Pytest multi process / multi thread execution test case
idea修改主体颜色
三菱M70宏变量读取三菱M80公共变量采集三菱CNC变量读取采集三菱CNC远程刀补三菱机床在线刀补三菱数控在线测量
leetcode刷题:二叉树08(N叉树的最大深度)
I was tortured by my colleague's null pointer for a long time, and finally learned how to deal with null pointer
Unity 绘制弹球和台球的运动轨迹
LNK2038 检测到“RuntimeLibrary”的不匹配项: 值“MD_DynamicRelease”不匹配值“MDd_DynamicDebug”(main.obj 中)
Distributed system: what, why, how
Rhcsa-- day one
随机推荐
疫情来袭--远程办公之思考|社区征文
How to dynamically cache components in Vue multi-level route nesting
Global exposure and roller shutter exposure of industrial cameras
pytest多进程/多线程执行测试用例
新型数据中心,助力加快构建以数据为关键要素的数字经济
Programmers' telecommuting is mixed | community essay solicitation
Two commonly used graphics can easily realize data display
Epidemic strikes -- Thinking about telecommuting | community essay solicitation
I Build a simple microservice project
TCP-三次握手和四次挥手简单理解
[Yugong series] go teaching course 002 go language environment installation in July 2022
01 qemu 启动编译好的镜像 VFS: Unable to mount root fs on unknown-block(0,0)
Balance between picture performance of unity mobile game performance optimization spectrum and GPU pressure
透过JVM-SANDBOX源码,了解字节码增强技术原理
JDBC 进阶
JDBC advanced
Flink learning 7: application structure
Graduation summary
Parameterization of controls in katalon
Smart subway | cloud computing injects wisdom into urban subway transportation