<!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"> img{ border:0; height:100px; width:150px; } td img{ margin:0 10px; } </style> </head> <body> <!-- 纵向向无缝滚动--> <div id="demo" style="overflow:hidden;height:350px;width:200px"> <div id="demo1"> <a href="#" target="_blank"><img src="http://www.cwydesign.com/effects/UploadFiles_7074/201008/2010081123451407.jpg"></a><p> <a href="#" target="_blank"><img src="http://www.cwydesign.com/effects/UploadFiles_7074/201008/2010081123451407.jpg"></a><p> <a href="#" target="_blank"><img src="http://www.cwydesign.com/effects/UploadFiles_7074/201008/2010081123451407.jpg"></a><p> <a href="#" target="_blank"><img src="http://www.cwydesign.com/effects/UploadFiles_7074/201008/2010081123451407.jpg"></a><p> <a href="#" target="_blank"><img src="http://www.cwydesign.com/effects/UploadFiles_7074/201008/2010081123451407.jpg"></a><p> <a href="#" target="_blank"><img src="http://www.cwydesign.com/effects/UploadFiles_7074/201008/2010081123451407.jpg"></a><p> <a href="#" target="_blank"><img src="http://www.cwydesign.com/effects/UploadFiles_7074/201008/2010081123451407.jpg"></a><p> <a href="#" target="_blank"><img src="http://www.cwydesign.com/effects/UploadFiles_7074/201008/2010081123451407.jpg"></a><p> <a href="#" target="_blank"><img src="http://www.cwydesign.com/effects/UploadFiles_7074/201008/2010081123451407.jpg"></a><p> <a href="#" target="_blank"><img src="http://www.cwydesign.com/effects/UploadFiles_7074/201008/2010081123451407.jpg"></a><p> </div> <div id="demo2"> </div> </div> <script> var speed=40; var demo2=document.getElementById("demo2"); var demo1=document.getElementById("demo1"); var demo=document.getElementById("demo"); 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 style="margin-top:20px;"> <div id="scroll_div" style="overflow: hidden; WIDTH: 778px;" align=center> <table border="0" cellpadding="0" cellspacing="0"> <tr> <td id="scroll_begin"> <a href="#"><img src="http://www.cwydesign.com/effects/UploadFiles_7074/201008/2010081123451407.jpg" border=0></a><a href="#"><img src="http://www.cwydesign.com/effects/UploadFiles_7074/201008/2010081123451407.jpg" border=0></a><a href="#"><img src="http://www.cwydesign.com/effects/UploadFiles_7074/201008/2010081123451407.jpg" border=0></a><a href="#"><img src="http://www.cwydesign.com/effects/UploadFiles_7074/201008/2010081123451407.jpg" border=0></a><a href="#"><img src="http://www.cwydesign.com/effects/UploadFiles_7074/201008/2010081123451407.jpg" border=0></a><a href="#"><img src="http://www.cwydesign.com/effects/UploadFiles_7074/201008/2010081123451407.jpg" border=0></a><a href="#"><img src="http://www.cwydesign.com/effects/UploadFiles_7074/201008/2010081123451407.jpg" border=0></a></td> <td id="scroll_end"></td> </tr> </table> </div></div> <script> var speed1=40 var scroll_end = document.getElementById("scroll_end"); var scroll_div = document.getElementById("scroll_div"); scroll_end.innerHTML=scroll_begin.innerHTML function Marquee1(){ if(scroll_end.offsetWidth-scroll_div.scrollLeft<=0) scroll_div.scrollLeft-=scroll_begin.offsetWidth else{ scroll_div.scrollLeft++ } } var MyMar1=setInterval(Marquee1,speed1) scroll_div.onmouseover=function() {clearInterval(MyMar1)} scroll_div.onmouseout=function() {MyMar1=setInterval(Marquee1,speed1)} </script>
</body> </html> |