层的无间断滚动效果

来源:互联网 发布:干程序员帅哥变 编辑:程序博客网 时间:2024/04/28 03:10

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>

<body>
<div style="width:100px; height:100px;">
<div  class="answer_left_in" id="demo" style="overflow:hidden; width:213px; height:100px;">
    <div id="demo1">
     这是第一行内容</br>    
     这是第二行内容</br> 
     这是第三行内容</br> 
     这是第四行内容</br> 
     这是第五行内容</br> 
     这是第六行内容</br> 
     这是第七行内容</br> 
     这是第八行内容</br> 
     这是第九行内容</br> 
     这是第十行内容</br> 
    </div>
    <div id="demo2"></div>
    </div>
<div>
<script type="text/javascript">
demo2.innerText=demo1.innerText;

function Marquee(){
 if(demo2.offsetTop-demo.scrollTop<=0){
  demo.scrollTop-=demo1.offsetHeight;
 }
 else{
  demo.scrollTop++;
 }
}

var time=setInterval(Marquee,10);

demo.onmouseover=function (){clearInterval(time)};
demo.onmouseout=function (){time=setInterval(Marquee,10);};
</script>

</body>
</html>

原创粉丝点击