Posted in Javascript onMarch 27, 2017
废话不多说了,直接给大家贴代码了,具体代码如下所示:
<!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" xml:lang="en"> <head> <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> <title>Document</title> <style type="text/css"> * { padding: 0; margin: 0; } .box { width: 600px; height: 200px; margin: 60px auto; overflow: hidden; position: relative; } ul { list-style-type: none; width: 2000px; position: absolute; top: 0; left: 0; } li { float: left; } </style> </head> <body> <div class="box" id="box"> <ul id="gun"> <li><img src="01.jpg" alt="" /></li> <li><img src="02.jpg" alt="" /></li> <li><img src="03.jpg" alt="" /></li> <li><img src="04.jpg" alt="" /></li> <li><img src="01.jpg" alt="" /></li> <li><img src="02.jpg" alt="" /></li> </ul> <script type="text/javascript"> var box = document.getElementById("box"); var gun = document.getElementById("gun"); function $(i){ return document.getElementsByTagName("img")[i]; } var num = 0; all(); function all(){ var shi= setInterval(fun,5); gun.onmouseover=function (){ clearInterval(shi); } gun.onmouseout=function (){ all(); } function fun(){ if(num<=-1200){ num=0; }else{ gun.style.left=num+"px"; num--; } } } </script> </div> </body> </html>
以上所述是小编给大家介绍的JavaScript无缝滚动效果的实例代码,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对三水点靠木网站的支持!
JavaScript无缝滚动效果的实例代码
- Author -
酷扬声明:登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述。
Reply on: @reply_date@
@reply_contents@