这是我自己用div改写的图片滚动代码,可是不能滚动图片,不知道错在哪里<!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>
<style type="text/css">
<!--
#demo {
height: 100px;
width: 1300px;
background-color: #ADADAD;

}
#demoscroll {
height: 100px;
width: 300px;
background-color: #ADADAD;
overflow: hidden;
}
#demo1{
float: left;
width:600;
height: 100px;

}
#demo2{
float: left;
height: 100px;
width: 600px;

}
.pic{ 
    float: left;
height: 100px;
width: 100px;
background-color:#0000FF
}
-->
</style>
</head>
<body>
<div id="demoscroll">
  <div id="demo">
 
    <div id="demo1">
      <div class="pic"><img name="a" src="" width="200" height="100" alt="a" /> </div>
      <div class="pic"><img name="b" src="" width="200" height="100" alt="b" /> </div>
      <div class="pic"> <img name="c" src="" width="200" height="100" alt="c" /></div>
    </div>
    <div id="demo2"> </div>
  </div>
</div><script type="text/javascript"> 
var speed=50 ;
demo2.innerHTML=demo1.innerHTML ;function Marquee(){ if(demo1.offsetWidth-demo.scrollLeft<=1) 
demo.scrollLeft=0; 
else{ 
demo.scrollLeft=demo.scrollLeft+1;


var MyMar=setInterval(Marquee,speed) 
demo.onmouseover=function() {clearInterval(MyMar)} 
demo.onmouseout=function() {MyMar=setInterval(Marquee,speed)} 
</script> 
</body>
</html>

解决方案 »

  1.   

    <div id=demo style=overflow:hidden;height:50px>
    <div id=demo1>
    111111111111111<br>
    222222222222222<br>
    333333333333333<br>
    444444444444444<br>
    555555555555555<br>
    </div>
    <div id=demo2></div>
    </div>
    <script>
    var speed=50
    demo2.innerText=demo1.innerText;
    function Marquee(){
    demo.scrollTop++;
    if(demo2.offsetTop<=demo.scrollTop) demo.scrollTop-=demo1.offsetHeight; 
    }
    var Mar=setInterval(Marquee,speed)
    demo.onmouseover=function() {clearInterval(Mar)}
    demo.onmouseout=function() {MyMar=setInterval(Marquee,speed)}
    </script>你参考一下把