当前位置:网站首页>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>
边栏推荐
- Pandora IOT development board learning (HAL Library) - Experiment 6 independent watchdog experiment (learning notes)
- Is it really so difficult to learn redis? Today, a fan will share his personal learning materials!
- 疫情来袭--远程办公之思考|社区征文
- SQL语句加强练习(MySQL8.0为例)
- 新型数据中心,助力加快构建以数据为关键要素的数字经济
- Katalon framework tests web (XXI) to obtain element attribute assertions
- functools下的reduce函数
- Katalon使用script实现查询List大小
- warning: LF will be replaced by CRLF in XXXXXX
- Myslq delete followed by limit
猜你喜欢

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

Katalon中控件的参数化
![[PaddleSeg 源码阅读] PaddleSeg 自定义数据类](/img/88/37c535b371486db545abc392a685af.png)
[PaddleSeg 源码阅读] PaddleSeg 自定义数据类

Nbear introduction and use diagram

Typical applications of minimum spanning tree

PostgreSQL users cannot create table configurations by themselves

ctf-pikachu-XSS

Defensive programming skills
![[source code analysis] model parallel distributed training Megatron (5) -- pipestream flush](/img/94/2bdc31ec05595dbbc8a7a8d6b22252.jpg)
[source code analysis] model parallel distributed training Megatron (5) -- pipestream flush

MySQL one master multiple slaves + linear replication
随机推荐
[Yugong series] go teaching course 002 go language environment installation in July 2022
Penetration practice - sqlserver empowerment
Summary of Chinese remainder theorem
三菱M70宏变量读取三菱M80公共变量采集三菱CNC变量读取采集三菱CNC远程刀补三菱机床在线刀补三菱数控在线测量
Balance between picture performance of unity mobile game performance optimization spectrum and GPU pressure
vue多级路由嵌套怎么动态缓存组件
Katalon框架测试web(二十六)自动发邮件
[.NET + mqtt]. Mise en œuvre de la communication mqtt dans l'environnement net 6 et démonstration de code pour l'abonnement et la publication de messages bilatéraux du serveur et du client
PostgreSQL users cannot create table configurations by themselves
idea修改主体颜色
[PaddleSeg 源码阅读] PaddleSeg 自定义数据类
[Huawei cloud IOT] reading notes, "Internet of things: core technology and security of the Internet of things", Chapter 3 (I)
数据库SQL语句汇总,持续更新......
super_ Subclass object memory structure_ Inheritance tree traceability
2022-07-03:数组里有0和1,一定要翻转一个区间,翻转:0变1,1变0。 请问翻转后可以使得1的个数最多是多少? 来自小红书。3.13笔试。
渗透实战-SQLServer提权
Typical applications of minimum spanning tree
Which product is better if you want to go abroad to insure Xinguan?
Deep thinking on investment
02 ls 命令的具体实现