css百叶窗滚动
<!<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <head> <meta charset="utf-8"> <title></title> <style> *{ margin:0; padding:0; } #ul1{ width:250px; height:auto; float:left; border-top:1px solid #000; margin:20px; } li{ list-style:none; width:100%; height:30px; line-height:30px; overflow:hidden; position:relative; border-bottom:1px dotted #333; } li div{ position:absolute; top:-30px; } li div p{ height:30px; letter-spacing:5px; } </style> </head> <body> <ul id="ul1"> <li> <div> <p>1111111</p> <p>2222222</p> </div> </li> <li> <div> <p>3333333</p> <p>4444444</p> </div> </li> <li> <div> <p>5555555</p> <p>6666666</p> </div> </li> <li> <div> <p>7777777</p> <p>8888888</p> </div> </li> </ul> </body> <script type="text/javascript"> function startMove(obj,json,endFn){ clearInterval(obj.timer); obj.timer = setInterval(function(){ var bBtn = true; for(var attr in json){ var iCur = 0; if(attr == 'opacity'){ if(Math.round(parseFloat(getStyle(obj,attr))*100)==0){ iCur = Math.round(parseFloat(getStyle(obj,attr))*100); } else{ iCur = Math.round(parseFloat(getStyle(obj,attr))*100) || 100; } } else{ iCur = parseInt(getStyle(obj,attr)) || 0; } var iSpeed = (json[attr] - iCur)/8; iSpeed = iSpeed >0 ? Math.ceil(iSpeed) : Math.floor(iSpeed); if(iCur!=json[attr]){ bBtn = false; } if(attr == 'opacity'){ obj.style.filter = 'alpha(opacity=' +(iCur + iSpeed)+ ')'; obj.style.opacity = (iCur + iSpeed)/100; } else{ obj.style[attr] = iCur + iSpeed + 'px'; } } if(bBtn){ clearInterval(obj.timer); if(endFn){ endFn.call(obj); } } },30); } function getStyle(obj,attr){ if(obj.currentStyle){ return obj.currentStyle[attr]; } else{ return getComputedStyle(obj,false)[attr]; } } </script> <script> window.onload=function(){ var ul1=document.getElementById("ul1"); toShow(ul1); function toShow(obj){ var aDiv=obj.getElementsByTagName("div"); var inow=0; var timer=null; var btn=true; setInterval(function(){ toChange(); },4000); function toChange(){ timer = setInterval(function(){ if(inow==aDiv.length){ clearInterval(timer); inow=0; btn=!btn; }else if(btn){ startMove(aDiv[inow],{top:0}); inow++; }else{ startMove(aDiv[inow],{top:-30}); inow++; } },100); } } } </script>