当前位置:网站首页>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>
边栏推荐
- [PaddleSeg 源码阅读] PaddleSeg Transform 的 Normalize操作
- Mindmanager2022 efficient and easy to use office mind map MindManager
- Session learning diary 1
- pytest多进程/多线程执行测试用例
- SQL語句加强練習(MySQL8.0為例)
- 基于PHP的轻量企业销售管理系统
- Brief explanation of depth first search (with basic questions)
- Redis cluster view the slots of each node
- Database SQL statement summary, continuous update
- 三菱M70宏变量读取三菱M80公共变量采集三菱CNC变量读取采集三菱CNC远程刀补三菱机床在线刀补三菱数控在线测量
猜你喜欢

The maximum expiration time of client secret in azure ad application registration is modified to 2 years

三菱M70宏变量读取三菱M80公共变量采集三菱CNC变量读取采集三菱CNC远程刀补三菱机床在线刀补三菱数控在线测量

Perf simple process for multithreaded profile

深度优先搜索简要讲解(附带基础题)
![CesiumJS 2022^ 源码解读[0] - 文章目录与源码工程结构](/img/ba/c1d40de154344ccc9f2fd1dd4cb12f.png)
CesiumJS 2022^ 源码解读[0] - 文章目录与源码工程结构

函数计算异步任务能力介绍 - 任务触发去重

拼夕夕二面:说说布隆过滤器与布谷鸟过滤器?应用场景?我懵了。。

SQL statement strengthening exercise (MySQL 8.0 as an example)

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

Nbear introduction and use diagram
随机推荐
logistic regression
Defensive programming skills
SDP中的SPA
National standard gb28181 protocol platform easygbs fails to start after replacing MySQL database. How to deal with it?
支持首次触发的 Go Ticker
【读书会第十三期】多媒体处理工具 FFmpeg 工具集
Smart subway | cloud computing injects wisdom into urban subway transportation
pytest多进程/多线程执行测试用例
Katalon使用script实现查询List大小
10 reasons for not choosing to use free virtual hosts
Infiltration practice guest account mimikatz sunflower SQL rights lifting offline decryption
LevelDB源码解读-SkipList
Introduction to asynchronous task capability of function calculation - task trigger de duplication
Management and thesis of job management system based on SSM
warning: LF will be replaced by CRLF in XXXXXX
渗透实战-SQLServer提权
02 ls 命令的具体实现
深入浅出对话系统——使用Transformer进行文本分类
三年进账35.31亿,这个江西老表要IPO了
ctf-pikachu-XSS