当前位置:网站首页>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>
边栏推荐
- Storage of MySQL database
- What kind of experience is it when the Institute earns 20000 yuan a month!
- 三菱M70宏变量读取三菱M80公共变量采集三菱CNC变量读取采集三菱CNC远程刀补三菱机床在线刀补三菱数控在线测量
- Recursive structure
- XSS prevention
- Activiti7 task service - process variables (setvariable and setvariablelocal)
- Infiltration practice guest account mimikatz sunflower SQL rights lifting offline decryption
- How about the ratings of 2022 Spring Festival Gala in all provinces? Map analysis helps you show clearly!
- Perf simple process for multithreaded profile
- 三年进账35.31亿,这个江西老表要IPO了
猜你喜欢
Evolution of MySQL database architecture
Activiti7 task service - process variables (setvariable and setvariablelocal)
Es network layer
拼夕夕二面:说说布隆过滤器与布谷鸟过滤器?应用场景?我懵了。。
How about the ratings of 2022 Spring Festival Gala in all provinces? Map analysis helps you show clearly!
Introduction to asynchronous task capability of function calculation - task trigger de duplication
Mitsubishi M70 macro variable reading Mitsubishi M80 public variable acquisition Mitsubishi CNC variable reading acquisition Mitsubishi CNC remote tool compensation Mitsubishi machine tool online tool
微信公众号网页授权
[paddleseg source code reading] paddleseg custom data class
函数计算异步任务能力介绍 - 任务触发去重
随机推荐
基于PHP的轻量企业销售管理系统
Katalon使用script实现查询List大小
Mitsubishi M70 macro variable reading Mitsubishi M80 public variable acquisition Mitsubishi CNC variable reading acquisition Mitsubishi CNC remote tool compensation Mitsubishi machine tool online tool
[source code analysis] model parallel distributed training Megatron (5) -- pipestream flush
Zigzag scan
Redis cluster uses Lua script. Lua script can also be used for different slots
毕业总结
How to dynamically cache components in Vue multi-level route nesting
微信公众号网页授权
10 reasons for not choosing to use free virtual hosts
【webrtc】m98 ninja 构建和编译指令
[Huawei cloud IOT] reading notes, "Internet of things: core technology and security of the Internet of things", Chapter 3 (I)
Go 语言入门很简单:Go 实现凯撒密码
Class summation, shortest row
pytest多进程/多线程执行测试用例
Database SQL statement summary, continuous update
投资深度思考
Pandora IOT development board learning (HAL Library) - Experiment 6 independent watchdog experiment (learning notes)
JSON string conversion in unity
Epidemic strikes -- Thinking about telecommuting | community essay solicitation