文字向左无缝滚动 marquee 标签
用这个标签做滚动可能已经过时了,但真的是狠好用,超级解决问题!
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
*{padding: 0;margin: 0;}
.scrollbox{background:#f60;width:384px;padding:0 10px;overflow: hidden; white-space:nowrap;height: 40px;line-height: 40px;}
.scrollbox h1{color: #fff;font-family:微软雅黑!important;font-weight: bold;font-size: 24px;}
</style>
</head>
<body>
<div class="scrollbox">
<marquee name=news behavior=scroll direction=left scrollamount=2 scrolldelay=1 hspace=0 vspace=0 onMouseOver="this.stop()" onMouseOut="this.start()" >
<h1>滚动测试内容测试内容测试内容,滚动测试内容测试内容测试内容</h1>
</marquee>
</div>
<script>
<!-- Begin
var ostat = false;
function scrollstop() {
news.scrollAmount = 0;
ostat = true;
}
function scrollplay() {
news.scrollAmount = 5;
ostat = false;
}
function scrolldir() {
mid = screen.width / 2;
mouse = event.x;
if(mouse > mid) {
if(ostat == false) {
speed = (mouse - mid) / 25;
news.scrollAmount = speed;
}
news.direction = "right";
}
else {
if(ostat == false) {
speed = (mid - mouse) / 25;
news.scrollAmount = speed;
}
news.direction = "left";
}
}
// End -->
</script>
</body>
</html>