一个无缝滚动代码(兼容IE、FF)

来源:互联网 发布:什么编程软件好用 编辑:程序博客网 时间:2024/05/22 00:15
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>左右无间断滚动</title>
<style type="text/css" media="all">
.d1 {
 margin:10px auto;
 width:200px;
 border:#103E63 1px solid;
 background-color:#EFEFEF;
 height:auto;
 overflow:hidden;
 white-space:nowrap;
}
.d2 {
 margin:0px auto;
 background-color:#FF9933;
}
.div2 {
 width:auto;
 height:auto;
 font-size:12px;
 float:left;
 overflow:hidden;
}
ul{
margin:0px;
padding:9px;
list-style:none;
line-height:19px;
font-size:12px;
}
a:link,a:visited{
color:#3F78CF;
text-decoration:none;
}
a:hover{
color:#FF00CC;
text-decoration:underline;
}
</style>
<script language="javascript" type="text/javascript">
var s,s2,s3,s4,timer;
function init(){
s=getid("div1");
s2=getid("div2");
s3=getid("div3");
s4=getid("scroll");
s4.style.width=(s2.offsetWidth*2+100)+"px";
s3.innerHTML=s2.innerHTML;
timer=setInterval(mar,30)
}
function mar(){
if(s2.offsetWidth<=s.scrollLeft){
s.scrollLeft-=s2.offsetWidth;
}else{s.scrollLeft++;}
}
function getid(id){
return document.getElementById(id);
}
window.onload=init;
</script>
</head>
<body>
<div class="d1" id="div1" onmouseover="clearInterval(timer)" onmouseout="timer=setInterval(mar,30)">
   <div class="scroll" id="scroll">
     <div class="div2" id="div2">
        <ul>
          <li><a href="/Item/80.aspx" target="_self">考察合川网络信息建设情况</a></li>
          <li><a href="/Item/79.aspx" target="_self">政协委员视察大石镇农业特色产业</a></li>
          <li><a href="/Item/78.aspx" target="_self">对接好融资渠道 加快推进项目建设</a></li>
          <li><a href="/Item/77.aspx" target="_self">重庆市油菜高产创建现场培训会在合召开</a></li>
          <li><a href="/Item/76.aspx" target="_self">合川区人大常委会举行纪念改革开放30周年…</a></li>
        </ul>
  </div>
  <div id="div3" class="div2"></div>
 </div>
</div>
</body>
</html>
原创粉丝点击