可自定义速度的js图片无缝滚动示例分享 |
本文标签:图片无缝滚动,js图片滚动 思路: 一组图片 控制它的滚动条进行滚动 且此时对这组图片进行复制并添加进原图片组中,现在就有两组图片了 。你可以想象一下,现在滚动条继续滚动,原来那组图片最后一张图片已经滚至顶端且消失,复制的那组图片的第一张跟在原图最后一张图片后出现,此时你就能感觉到无缝滚动了 。 复制代码 代码如下: <!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=utf-8" /> <title>JS图片向左滚动</title> <style type="text/css"> img{ border: none; } </style> </head> <body> <div id="demo" style="overflow:hidden;width:500px;"> <table border=0 align=center cellpadding=1 cellspacing=1 cellspace=0 > <tr> <td id="demo1" valign="top" bgcolor="ffffff"> <!-- 特别注意,下面的图片总宽度必须大于上面定义的demo的宽度,如上面demo的宽度为500px,则下面图片总宽度必须大于500,否则会出现些问题! --> <table border="0" cellspacing="0" cellpadding="0"> <tr align="center"> <td><a href="#" target="_blank"><img src="images/1.jpg" width="150" height="100"></a></td> <td><a href="#" target="_blank"><img src="images/2.jpg" width="150" height="100"></a></td> <td><a href="#" target="_blank"><img src="images/3.jpg" width="150" height="100"></a></td> <td><a href="#" target="_blank"><img src="images/4.jpg" width="150" height="100"></a></td> <td><a href="#" target="_blank"><img src="images/5.jpg" width="150" height="100"></a></td> </tr> </table> </td> <td id="demo2" valign="top"> </td> </tr> </table> </div> <div id="msg"></div> <script type="text/javascript"> //0:定速度 |