打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
Js单行图片文字滚动

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

02 <html xmlns="http://www.w3.org/1999/xhtml">
03 <head>
04 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
05 <title>文字,图片向上滚动效果</title>
06 <style type="text/css">
07 body{ font-size:12px; font-family:Arial, Helvetica, sans-serif; color:#666; line-height:2em; background:#000;}
08 #rollBox{ height:25px; width:220px; overflow:hidden; border:2px solid #CCC; list-style:none; margin:0; padding:0; position:relative; padding-left:5px; margin:50px auto; background:#FFf; cursor:pointer;}
09 #imgRollBox{ height:73px; width:229px; overflow:hidden; border:2px solid #CCC; list-style:none; margin:0; padding:0; position:relative;margin:50px auto; background:#FFf;cursor:pointer;}
10 ul li,ul{ margin:0; padding:0;}
11 img{ display:block;}
12 </style>
13 </head>
14 <body>
15     <ul id="rollBox">
16         <li>[1]hello world i love this job! do you?</li>
17         <li>[2]hello world i love this job! do you?</li>
18         <li>[3]hello world i love this job! do you?</li>
19         <li>[4]hello world i love this job! do you?</li>
20         <li>[5]hello world i love this job! do you?</li>
21     </ul>
22     <ul id="imgRollBox">
23         <li><img border="0" src="24178817.jpg" name="page_cnt_3"/></li>
24         <li><img  border="0"  src="24178819.jpg" name="page_cnt_3"/></li>
25          <li><img border="0" src="24178817.jpg" name="page_cnt_3"/></li>
26         <li><img  border="0"  src="24178819.jpg" name="page_cnt_3"/></li>
27   
28     </ul>
29 <script type="text/javascript">
30 var rollText={
31     go:null,
32     oParentUl:null,
33     oUlH:null,
34     liArr:null,
35     childNode:null,
36     timeout:null,
37     run:function(id,delay){
38         var oLiFirst=this.liArr[0];
39         var liMarTop = oLiFirst.style.marginTop;
40         var liTopNum=parseInt(liMarTop);
41         var c = Math.abs(liTopNum);
42         if(c< parseInt(this.oUlH)){
43             c++;
44             oLiFirst.style.marginTop ='-' + c + 'px';
45         }else if(Math.abs(liTopNum)== parseInt(this.oUlH)){
46             clearInterval(this.go);
47             this.oParentUl.removeChild(oLiFirst);
48             this.oParentUl.appendChild(oLiFirst);
49             this.liArr[this.liArr.length-1].style.marginTop='0px';
50             this.timeout=setTimeout(function(obj,id,childtags,delay){return function(){obj.start(id,childtags,delay);};}(this,id,this.childNode,delay),delay);
51         }
52           
53     },
54     start:function(id,childtags,delay){
55           
56         this.childNode=childtags;
57         this.oParentUl=document.getElementById(id);
58         this.oUlH=this.oParentUl.currentStyle?this.oParentUl.currentStyle['height']:window.getComputedStyle(this.oParentUl,null)['height'];
59         this.liArr=this.oParentUl.getElementsByTagName(childtags);
60         for(var i=0;i<this.liArr.length;i++){
61             this.liArr[i].style.cssText +=';margin-top:0;height:'+this.oUlH+';line-height:'+this.oUlH+';display:block; width:100%;';
62               
63         }
64         this.go =setInterval(
65              function(obj,id,delay){
66             return function(){obj.run(id,delay)}
67         }(this,id,delay),10);
68         this.oParentUl.onmouseover=function(obj){return function(){clearTimeout(obj.timeout);clearTimeout(obj.go);};}(this);
69         this.oParentUl.onmouseout=function(obj){return function(){obj.go =setInterval(function(obj,id,delay){return function(){obj.run(id,delay)};}(obj,id,delay),10);};}(this);
70           
71     }
72 }
73 rollText.start('rollBox','li',1000);
74 function clone(){};
75 clone.prototype= rollText;
76 var obj = new clone;
77 obj.start('imgRollBox','li',1000);
78 </script>
79 </body>
80 </html>
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
常用作帖、发帖代码集萃
图片轮播代码2(html)
jquery无缝向上滚动实现代码
好看的js幻灯效果,图片切换轮播代码
javascript小技巧
JS按钮控制内容上下滚动
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服