|
热门文章 |
|
|
|
|
JS图片滚动代码(无缝、平滑) |
来源:源码爱好者 更新时间:2009/12/31 15:14:08 阅读次数: 我要投稿 |
|
<!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>JS图片滚动代码(无缝、平滑)</title> </head> <body> <style type="text/css"> <!-- #demo { background: #FFF; overflow:hidden; border: 1px dashed #CCC; width: 500px; } #demo img { border: 3px solid #F2F2F2; } #indemo { float: left; width: 800%; } #demo1 { float: left; } #demo2 { float: left; } --> </style> <div id="demo"> <div id="indemo"> <div id="demo1"> <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/2010081123451445.jpg" border="0" /></a> <a href="#"><img src="http://www.cwydesign.com/effects/UploadFiles_7074/201008/2010081123451423.jpg" border="0" /></a> <a href="#"><img src="http://www.cwydesign.com/effects/UploadFiles_7074/201008/2010081123451462.jpg" border="0" /></a> <a href="#"><img src="http://www.cwydesign.com/effects/UploadFiles_7074/201008/2010081123451490.jpg" border="0" /></a> <a href="#"><img src="http://www.cwydesign.com/effects/UploadFiles_7074/201008/2010081123451473.jpg" border="0" /></a> </div> <div id="demo2"></div> </div> </div> <script> <!-- var speed=10; var tab=document.getElementById("demo"); var tab1=document.getElementById("demo1"); var tab2=document.getElementById("demo2"); tab2.innerHTML=tab1.innerHTML; function Marquee(){ if(tab2.offsetWidth-tab.scrollLeft<=0) tab.scrollLeft-=tab1.offsetWidth else{ tab.scrollLeft++; } } var MyMar=setInterval(Marquee,speed); tab.onmouseover=function() {clearInterval(MyMar)}; tab.onmouseout=function() {MyMar=setInterval(Marquee,speed)}; --> </script> </body> </html> |
特效说明: |
非常平滑的JS图片滚动特效代码,无缝循环,速度可自定义,鼠标悬停时停止。它的特点是JS和图片地址分离,这样做你就经易的从数据库动态调用每张图片的地址,方便控制,因此它非常的应用。 |
|
上一篇文章: 遮罩过渡效果的图片幻灯和选项卡菜单下一篇文章: 可控制左右滚动的无缝图片滚动特效 |
|
|