<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
<style type="text/css">
ul li
{
height: 30px;
}
</style>
</head>
<body>
<div id="demo" style="height: 50px; overflow:hidden;border: 1px solid #000;">
<div id="demo1">
<ul>
<li>di yitiao xinwen</li>
<li>di yitiao xinwen</li>
<li>di yitiao xinwen</li>
<li>GGGGGGGGGGGGG</li>
</ul>
</div>
<div id="demo2"></div>
</div>
<script>
var speed = 50
demo2.innerHTML = demo1.innerHTML
function Marquee() {
if (demo2.offsetTop - demo.scrollTop <= 0)
demo.scrollTop -= demo1.offsetHeight
else {
demo.scrollTop++
}
}
var MyMar = setInterval(Marquee, speed)
demo.onmouseover = function () { clearInterval(MyMar) }
demo.onmouseout = function () { MyMar = setInterval(Marquee, speed) }
</script>
</body>
</html>
原文地址:http://www.cnblogs.com/fengpiaoling/p/3853837.html