<div id="rollpic" style="overflow:hidden; width:150px; height:300px">
<div id="demo1">
<a href="#"><img src="images/flogo1.jpg" width="96" height="49" alt="f" /></a>
<a href="#"><img src="images/flogo2.jpg" width="96" height="49" alt="f" /></a>
<a href="#"><img src="images/flogo3.jpg" width="96" height="49" alt="f" /></a>
<a href="#"><img src="images/flogo4.jpg" width="96" height="49" alt="f" /></a>
<a href="#"><img src="images/flogo5.jpg" width="96" height="49" alt="f" /></a>
</div>
<div id="demo2"></div>
</div>
<script>
var speed=30;
var tab=document.getElementById("rollpic");
var tab1=document.getElementById("demo1");
var tab2=document.getElementById("demo2");
tab2.innerHTML=tab1.innerHTML;
function Marquee(){
if(tab2.offsetHeight-tab.scrollTop<0)
tab.scrollTop-=tab2.offsetHeight;
else{
tab.scrollTop++;
}
}
var MyMar=setInterval(Marquee,speed);
tab.onmouseover=function() {clearInterval(MyMar)};
tab.onmouseout=function() {MyMar=setInterval(Marquee,speed)};
</script>
滚了几遍就停下来了,怎么办?
<div id="demo1">
<a href="#"><img src="images/flogo1.jpg" width="96" height="49" alt="f" /></a>
<a href="#"><img src="images/flogo2.jpg" width="96" height="49" alt="f" /></a>
<a href="#"><img src="images/flogo3.jpg" width="96" height="49" alt="f" /></a>
<a href="#"><img src="images/flogo4.jpg" width="96" height="49" alt="f" /></a>
<a href="#"><img src="images/flogo5.jpg" width="96" height="49" alt="f" /></a> <a href="#"><img src="images/flogo1.jpg" width="96" height="49" alt="f" /></a>
<a href="#"><img src="images/flogo2.jpg" width="96" height="49" alt="f" /></a>
<a href="#"><img src="images/flogo3.jpg" width="96" height="49" alt="f" /></a>
<a href="#"><img src="images/flogo4.jpg" width="96" height="49" alt="f" /></a>
<a href="#"><img src="images/flogo5.jpg" width="96" height="49" alt="f" /></a>
</div>
<div id="demo2"></div>
</div>
if(tab2.offsetHeight-tab.scrollTop<=56){
多加点图片,正常滚动时,看看滚动条的变化规律,这样理解起来比较直观。
多加点图片,正常滚动时,看看滚动条的变化规律,这样理解起来比较直观。