新闻间隔滚动效果

 

标记一下来。

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 <meta http-equiv="Content-Language" content="zh-CN" />
 <meta name="Keywords" content="" />
 <meta name="Description" content="" />
 <title>间隔新闻滚动</title>
 <style type="text/css">

  * { margin:0; padding:0; font:normal normal 12px/1.5em "Arial"; }
  ul li { list-style:none;}
  #scroll { width:300px; overflow:hidden; height:20px;  margin:50px auto; border:1px solid red; text-align:center;}
 </style>
 
</head>

<body>
 <ul id="scroll">
  <li ><a href="#">新闻一</a></li>
  <li ><a href="#">新闻二</a></li>
  <li ><a href="#">新闻三</a></li>
  <li ><a href="#">新闻四</a></li>
 </ul>
<script language="javascript" type="text/javascript">
window.οnlοad=function(){
    var o=document.getElementById('scroll');
    var t=setInterval(function(){scrollup(o,24,0);},2000);
    o.οnmοuseοver=function(){clearInterval(t)};
    o.οnmοuseοut=function(){t=setInterval(function(){scrollup(o,24,0);},2000)}
}
///滚动主方法
///参数:o 滚动块对象
///参数:d 每次滚屏高度
///参数:c 当前已滚动高度
function scrollup(o,d,c){
    if(d==c){
        var t=getFirstChild(o.firstChild).cloneNode(true);
        o.removeChild(getFirstChild(o.firstChild));
        o.appendChild(t);
        t.style.marginTop="0px";
    }else{
        c+=2;
        getFirstChild(o.firstChild).style.marginTop=-c+"px";
        window.setTimeout(function(){scrollup(o,d,c)},20);
    }
}
//解决firefox下会将空格回车作为节点的问题
function getFirstChild(node){
  while (node.nodeType!=1)
  {
         node=node.nextSibling;
  }
  return node;
}
</script>
</body>

</html>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值