头闻号

杭州翰蕙服装有限公司

女装|彩妆化学品|皮肤用化学品|洗面奶|综合性公司

首页 > 新闻中心 > 科技常识:div图片marquee无缝连接实现代码
科技常识:div图片marquee无缝连接实现代码
发布时间:2024-09-30 06:27:19        浏览次数:3        返回列表

今天小编跟大家讲解下有关div图片marquee无缝连接实现代码 ,相信小伙伴们对这个话题应该有所关注吧,小编也收集到了有关div图片marquee无缝连接实现代码 的相关资料,希望小伙伴们看了有所帮助。

复制代码代码如下: <html> <head> <style type="text/css"> <!-- #demo { background: none repeat scroll 0 0 #FFFFFF; border: 1px solid #98CBFF; margin-bottom: 10px; margin-left: 5px; overflow: hidden; padding: 0 0 5px; width: 948px; } #demo img { border: 3px solid #F2F2F2; } #indemo { float: left; width: 800%; } #demo1 { float: left; } #demo2 { float: left; } .box { border: 1px solid #98CBFF; float: left; margin: 7px 10px; overflow: hidden; padding: 5px; width: 150px; } --> </style> </head> <body> 图片向左无缝滚动 向左滚动 复制代码代码如下: <div id="demo"> <div id="indemo"> <div id="demo1"> <div class="box"> <a href=""><img src="http://www.cnrui.cn/other/link/Clear_logo.gif"border="0"/></a> <p>你号</p>hello </div> <div class="box"> <a href=""><img src="http://www.cnrui.cn/other/link/Clear_logo.gif"border="0"/></a> <p>白痴</p>stupid </div> <div class="box"> <a href=""><img src="http://www.cnrui.cn/other/link/Clear_logo.gif"border="0"/></a> </div> </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>

来源:爱蒂网