公告通知的左右滚动
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
* {
margin: 0;
padding: 0;
}
body {
font-family: "microsoft yahei", "宋体";
color: #333;
font-size: 16px;
background-position: 0px 170px
}
li {
list-style: none;
}
input,
button,
img {
outline: none;
border: none;
}
a,
a:visited,
a:link {
text-decoration: none;
color: #333;
}
a:hover {
color: #333;
text-decoration: none;
}
.llbr_01 {
width: 800px;
margin: 0 auto;
}
</style>
</head>
<body>
<div class="llbr_01">
<div><a href="#" target="_blank" style="color:red;">英雄</a></div>
<div id="marquee1" style="width:468px;height: 38px;float: left;overflow: hidden;">
<div style="width:8000px;height: 38px; background:none;margin-left: 0;">
<ul id="marquee1_1" style="float:left;">
<li style="float: left; width: 68px; text-align: center; height: 38px;margin-top: 0;"><a href="#"
target="_blank" style="color: #333; font-size:16px;">石头人</a></li>
<li style="float: left; width: 68px; text-align: center; height: 38px;margin-top: 0;"><a href="#"
target="_blank" style="color: #333; font-size:16px;">小鱼人</a></li>
<li style="float: left; width: 68px; text-align: center; height: 38px;margin-top: 0;"><a href="#"
target="_blank" style="color: #333; font-size:16px;">亚索</a></li>
<li style="float: left; width: 68px; text-align: center; height: 38px;margin-top: 0;"><a href="#"
target="_blank" style="color: #333; font-size:16px;">炸弹人</a></li>
<li style="float: left; width: 68px; text-align: center; height: 38px;margin-top: 0;"><a href="#"
target="_blank" style="color: #333; font-size:16px;">女枪</a></li>
<li style="float: left; width: 68px; text-align: center; height: 38px;margin-top: 0;"><a href="#"
target="_blank" style="color: #333; font-size:16px;">奥拉夫</a></li>
<li style="float: left; width: 68px; text-align: center; height: 38px;margin-top: 0;"><a href="#"
target="_blank" style="color: #333; font-size:16px;">盲僧</a></li>
<li style="float: left; width: 68px; text-align: center; height: 38px;margin-top: 0;"><a href="#"
target="_blank" style="color: #333; font-size:16px;">阿卡丽</a></li>
<li style="float: left; width: 68px; text-align: center; height: 38px;margin-top: 0;"><a href="#"
target="_blank" style="color: #333; font-size:16px;">机器人</a></li>
<li style="float: left; width: 68px; text-align: center; height: 38px;margin-top: 0;"><a href="#"
target="_blank" style="color: #333; font-size:16px;">德莱文</a></li>
</ul>
<ul id="marquee1_2" style="float:left;">
</ul>
</div>
</div>
</div>
<script type="text/javascript">
//js无缝滚动代码
function marquee(i, direction) {
var obj = document.getElementById("marquee" + i);
var obj1 = document.getElementById("marquee" + i + "_1");
var obj2 = document.getElementById("marquee" + i + "_2");
if (direction == "up") {
if (obj2.offsetTop - obj.scrollTop <= 0) {
obj.scrollTop -= (obj1.offsetHeight + 20);
} else {
var tmp = obj.scrollTop;
obj.scrollTop++;
if (obj.scrollTop == tmp) {
obj.scrollTop = 1;
}
}
} else {
if (obj2.offsetWidth - obj.scrollLeft <= 0) {
obj.scrollLeft -= obj1.offsetWidth;
} else {
obj.scrollLeft++;
}
}
}
function marqueeStart(i, direction) {
var obj = document.getElementById("marquee" + i);
var obj1 = document.getElementById("marquee" + i + "_1");
var obj2 = document.getElementById("marquee" + i + "_2");
obj2.innerHTML = obj1.innerHTML;
var marqueeVar = window.setInterval("marquee(" + i + ", '" + direction + "')", 30);
obj.onmouseover = function () {
window.clearInterval(marqueeVar);
}
obj.onmouseout = function () {
marqueeVar = window.setInterval("marquee(" + i + ", '" + direction + "')", 30);
}
}
</script>
<script type="text/javascript">marqueeStart(1, "left");</script>
</body>
</html>
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通