当前位置:网站首页>JS实现文字滚动 跑马灯效果
JS实现文字滚动 跑马灯效果
2022-07-04 03:47: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">这是第一条啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊啊</span>
</div>
<div id="scroll_end"></div>
</div>
<script>
function ScrollImgLeft() {
var speed = 20;//初始化速度 也就是字体的整体滚动速度
var MyMar = null;//初始化一个变量为空 用来存放获取到的文本内容
var scroll_begin = document.getElementById("scroll_begin");//获取滚动的开头id
var scroll_end = document.getElementById("scroll_end");//获取滚动的结束id
var scroll_div = document.getElementById("scroll_div");//获取整体的开头id
scroll_end.innerHTML = scroll_begin.innerHTML;//滚动的是html内部的内容,原生知识!
//定义一个方法
function Marquee() {
if (scroll_end.offsetWidth - scroll_div.scrollLeft <= 0){
scroll_div.scrollLeft -= scroll_begin.offsetWidth;
} else{
scroll_div.scrollLeft++;
}
}
MyMar = setInterval(Marquee, speed);
//滑入暂停
scroll_div.onmouseover = function () {
clearInterval(MyMar);
}
//滑出继续
scroll_div.onmouseout = function () {
MyMar = setInterval(Marquee, speed);
}
}
ScrollImgLeft();
</script>
</body>
</html>
边栏推荐
- 如何有效远程办公之我见 | 社区征文
- vim映射命令
- 选择排序与冒泡排序模板
- Management and thesis of job management system based on SSM
- vue多级路由嵌套怎么动态缓存组件
- [untitled]
- LNK2038 检测到“RuntimeLibrary”的不匹配项: 值“MD_DynamicRelease”不匹配值“MDd_DynamicDebug”(main.obj 中)
- STM32 external DHT11 display temperature and humidity
- Introduction to asynchronous task capability of function calculation - task trigger de duplication
- 三年进账35.31亿,这个江西老表要IPO了
猜你喜欢
![[PaddleSeg 源码阅读] PaddleSeg 自定义数据类](/img/88/37c535b371486db545abc392a685af.png)
[PaddleSeg 源码阅读] PaddleSeg 自定义数据类
![[source code analysis] model parallel distributed training Megatron (5) -- pipestream flush](/img/98/3e5f1094141e34d7e77f908e12acda.jpg)
[source code analysis] model parallel distributed training Megatron (5) -- pipestream flush

Illustrated network: what is the hot backup router protocol HSRP?

JVM family -- monitoring tools

SQL語句加强練習(MySQL8.0為例)

SQL statement strengthening exercise (MySQL 8.0 as an example)
![Cesiumjs 2022^ source code interpretation [0] - article directory and source code engineering structure](/img/ba/c1d40de154344ccc9f2fd1dd4cb12f.png)
Cesiumjs 2022^ source code interpretation [0] - article directory and source code engineering structure

Katalon框架测试web(二十六)自动发邮件

MySQL one master multiple slaves + linear replication

Unity移动端游戏性能优化简谱之 画面表现与GPU压力的权衡
随机推荐
ctf-pikachu-CSRF
[paddleseg source code reading] paddleseg calculation dice
Support the first triggered go ticker
Brief explanation of depth first search (with basic questions)
MySQL one master multiple slaves + linear replication
Two sides of the evening: tell me about the bloom filter and cuckoo filter? Application scenario? I'm confused..
Detailed explanation of PPTC self recovery fuse
如何有效远程办公之我见 | 社区征文
Zigzag scan
Es network layer
Katalon框架测试web(二十一)获取元素属性断言
How to dynamically cache components in Vue multi-level route nesting
ctf-pikachu-CSRF
Class summation, shortest row
CUDA basic knowledge
Calculate the odd sum of 1~n (1~100 as an example)
拼夕夕二面:说说布隆过滤器与布谷鸟过滤器?应用场景?我懵了。。
Typical applications of minimum spanning tree
图解网络:什么是热备份路由器协议HSRP?
ctf-pikachu-XSS