- <style type="text/css">
- .shadowcon { width:100%; height:25px; margin:6px 5px 6px 10px; overflow:hidden;}
- #rollBox{ height:25px; width:100%; overflow:hidden;list-style:none; margin:0; padding:0; position:relative; padding-left:5px; margin:50px auto; background:#FFf; cursor:pointer;}
- .shadowcon li { list-style:none; line-height:25px; text-align:left;}
- </style>
- <div class="shadowcon">
- <ul id="rollBox" style="margin:5px 0 0 0;" name="rollBox">
- [loop]
- <li> <img alt="公告" src="http://www.ceczyz.com/images/web/index/gb.gif" width="15px" height="15px"><strong>网站公告:</strong><a href="{url}" title="{title}"{target}>{title}({starttime})</a></li>
- [/loop]
- </ul>
- </div>
- <script type="text/javascript">
- var rollText={
- go:null,
- oParentUl:null,
- oUlH:null,
- liArr:null,
- childNode:null,
- timeout:null,
- run:function(id,delay){
- var oLiFirst=this.liArr[0];
- var liMarTop = oLiFirst.style.marginTop;
- var liTopNum=parseInt(liMarTop);
- var c = Math.abs(liTopNum);
- if(c< parseInt(this.oUlH)){
- c++;
- oLiFirst.style.marginTop ='-' + c + 'px';
- }else if(Math.abs(liTopNum)== parseInt(this.oUlH)){
- clearInterval(this.go);
- this.oParentUl.removeChild(oLiFirst);
- this.oParentUl.appendChild(oLiFirst);
- this.liArr[this.liArr.length-1].style.marginTop='0px';
- this.timeout=setTimeout(function(obj,id,childtags,delay){return function(){obj.start(id,childtags,delay);};}(this,id,this.childNode,delay),delay);
- }
-
- },
- start:function(id,childtags,delay){
-
- this.childNode=childtags;
- this.oParentUl=document.getElementById(id);
- this.oUlH=this.oParentUl.currentStyle?this.oParentUl.currentStyle['height']:window.getComputedStyle(this.oParentUl,null)['height'];
- this.liArr=this.oParentUl.getElementsByTagName(childtags);
- for(var i=0;i<this.liArr.length;i++){
- this.liArr[i].style.cssText +=';margin-top:0;height:'+this.oUlH+';line-height:'+this.oUlH+';display:block; width:100%;';
-
- }
- this.go =setInterval(
- function(obj,id,delay){
- return function(){obj.run(id,delay)}
- }(this,id,delay),10);
- this.oParentUl.onmouseover=function(obj){return function(){clearTimeout(obj.timeout);clearTimeout(obj.go);};}(this);
- 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);
-
- }
- }
- rollText.start('rollBox','li',3000);
- function clone(){};
- clone.prototype= rollText;
- </script>
复制代码
这是效果图
演示:www.ceczyz.com
代码在上面
|