四种不同方式marquee图片不间断循环滚动代码(转)
向上:
<div id=demo style="overflow:hidden; width:128px; height:300px;">
<div id=demo1>
<img src="/gfjs.gif"><br><img src="/bxtt.gif"><br><img src="/bzjd.gif"><br>
<img src="/gfjs.gif"><br><img src="/bxtt.gif"><br><img src="/bzjd.gif"><br>
<img src="/gfjs.gif"><br><img src="/bxtt.gif"><br><img src="/bzjd.gif"><br>
<img src="/gfjs.gif"><br><img src="/bxtt.gif"><br><img src="/bzjd.gif"><br>
<img src="/gfjs.gif"><br><img src="/bxtt.gif"><br><img src="/bzjd.gif"><br>
<img src="/gfjs.gif"><br><img src="/bxtt.gif"><br><img src="/bzjd.gif"><br>
<img src="/gfjs.gif"><br><img src="/bxtt.gif"><br><img src="/bzjd.gif"><br>
<img src="/gfjs.gif"><br><img src="/bxtt.gif"><br><img src="/bzjd.gif"><br>
<img src="/gfjs.gif"><br><img src="/bxtt.gif"><br><img src="/bzjd.gif"><br>
<img src="/gfjs.gif"><br><img src="/bxtt.gif"><br><img src="/bzjd.gif"><br>
<img src="/gfjs.gif"><br><img src="/bxtt.gif"><br><img src="/bzjd.gif"><br>
</div>
<div id=demo2></div>
</div>
<script language="javascript">
var speed=30
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>
向下:
<div id=demo style="overflow:hidden; width:128px; height:300px;">
<div id=demo1>
<img src="/gfjs.gif"><br><img src="/bxtt.gif"><br><img src="/bzjd.gif"><br>
<img src="/gfjs.gif"><br><img src="/bxtt.gif"><br><img src="/bzjd.gif"><br>
<img src="/gfjs.gif"><br><img src="/bxtt.gif"><br><img src="/bzjd.gif"><br>
<img src="/gfjs.gif"><br><img src="/bxtt.gif"><br><img src="/bzjd.gif"><br>
<img src="/gfjs.gif"><br><img src="/bxtt.gif"><br><img src="/bzjd.gif"><br>
<img src="/gfjs.gif"><br><img src="/bxtt.gif"><br><img src="/bzjd.gif"><br>
<img src="/gfjs.gif"><br><img src="/bxtt.gif"><br><img src="/bzjd.gif"><br>
<img src="/gfjs.gif"><br><img src="/bxtt.gif"><br><img src="/bzjd.gif"><br>
<img src="/gfjs.gif"><br><img src="/bxtt.gif"><br><img src="/bzjd.gif"><br>
<img src="/gfjs.gif"><br><img src="/bxtt.gif"><br><img src="/bzjd.gif"><br>
<img src="/gfjs.gif"><br><img src="/bxtt.gif"><br><img src="/bzjd.gif"><br>
</div>
<div id=demo2></div>
</div>
<script language="javascript">
var speed=30
demo2.innerHTML=demo1.innerHTML
demo.scrollTop=demo.scrollHeight
function Marquee(){
if(demo1.offsetTop-demo.scrollTop>=0)
demo.scrollTop+=demo2.offsetHeight
else{
demo.scrollTop--
}
}
var MyMar=setInterval(Marquee,speed)
demo.onmouseover=function() {clearInterval(MyMar)}
demo.onmouseout=function() {MyMar=setInterval(Marquee,speed)}
</script>
向左:
<DIV id=demoleft style="OVERFLOW: hidden; WIDTH: 700px; COLOR: #ffffff">
<TABLE border=0 cellPadding=0 cellSpacing=0 cellspace="0">
<TBODY>
<TR>
<TD id=demo1left vAlign=top align=middle>
<TABLE cellSpacing=0 cellPadding=2 border=0>
<TBODY>
<TR align=middle>
<TD><img src="images/sysx/tp1.jpg" width="100" height="89" /></TD>
<TD><img src="images/sysx/tp2.jpg" width="100" height="89" /></TD>
<TD><img src="images/sysx/tp3.jpg" width="100" height="89" /></TD>
<TD><img src="images/sysx/tp4.jpg" width="100" height="89" /></TD>
<TD><img src="images/sysx/tp5.jpg" width="100" height="89" /></TD>
<TD><img src="images/sysx/tp6.jpg" width="100" height="89" /></TD>
<TD><img src="images/sysx/tp7.jpg" width="100" height="89" /></TD>
</TR></TBODY></TABLE></TD>
<TD id=demo2left vAlign=top></TD></TR></TBODY></TABLE></DIV>
<SCRIPT>
var speed=20//速度数值越大速度越慢,demo2.offsetWidth=demo1.offsetWidth=固定值
demo2left.innerHTML=demo1left.innerHTML
function Marquee(){
if(demo2left.offsetWidth-demoleft.scrollLeft<=0)//其实demo.scrollLeft是有 最大值的,和demo0.width,引用的图片的width有关系。demo过了一半(每半内容一样的),重新开始循环
demoleft.scrollLeft-=demo1left.offsetWidth
else{
demoleft.scrollLeft++//不断的增加,相当于父容器的滚动条不断是缩小;但由于OVERFLOW: hidden; (滚动条不可见)
}
}
var MyMarleft=setInterval(Marquee,speed)
demoleft.onmouseover=function() {clearInterval(MyMarleft)}
demoleft.onmouseout=function() {MyMarleft=setInterval(Marquee,speed)}
</SCRIPT>
向右:
<base
href="http://image2.sina.com.cn/gm/lineage2/whz/newwh/images/fy/images/images/ifimage/">
<div id=demo style="overflow:hidden;height:100px;width:300px;"><table align=left
cellpadding=0 cellspace=0 border=0><tr><td id=demo1 valign=top><img src="/gfjs.gif"><img
src="/bxtt.gif"><img src="/bzjd.gif"><img src="/gfjs.gif"><img src="/bxtt.gif"><img
src="/bzjd.gif"></td><td id=demo2 valign=top></td></tr></table></div>
<script>
var speed=30
demo2.innerHTML=demo1.innerHTML
demo.scrollLeft=demo.scrollWidth
function Marquee(){
if(demo.scrollLeft<=0)
demo.scrollLeft+=demo2.offsetWidth
else{
demo.scrollLeft--
}
}
var MyMar=setInterval(Marquee,speed)
demo.onmouseover=function() {clearInterval(MyMar)}
demo.onmouseout=function() {MyMar=setInterval(Marquee,speed)}
</script>
?
?