您的位置:首页 > 产品设计 > UI/UE

无缝循环左右MARQUEE js 兼容FF IE

2010-08-23 15:33 417 查看
<!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;
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 0px;
list-style:none;
line-height:19px;
font-size:12px;
}
li{
float:left;
line-height:22px;
margin:0px 6px;
text-align:center;
padding:0px;
border:#103E63 1px solid;
}
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*12+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">

<div class="pe_u_thumb"><a href="/Item/56.aspx"><img class="pic2" src="http://t3.baidu.com/it/u=2753395727,3816115492&fm=0&gp=-26.jpg" width="150" height="150" alt="“绿岛”与“天天唱”同台唱红歌" border="0" /></a></div>
<div class="pe_u_thumb_title"><a href="/Item/56.aspx">“绿岛”与“天天唱”...</a><br />
</div>

<div class="pe_u_thumb"><a href="/Item/51.aspx"><img class="pic2" src="http://t10.baidu.com/it/u=3296619699,1357979818&fm=0&gp=30.jpg" width="150" height="150" alt="微软称20日验证Windows与Office 盗版将黑屏" border="0" /></a></div>
<div class="pe_u_thumb_title"><a href="/Item/51.aspx">微软称20日验证Windows...</a><br />
</div>

<div class="pe_u_thumb"><a href="/Item/45.aspx"><img class="pic2" src="http://t3.baidu.com/it/u=3890301329,2572302646&fm=0&gp=14.jpg" width="150" height="150" alt="遂宁举办首届中国观音故里旅游节" border="0" /></a></div>
<div class="pe_u_thumb_title"><a href="/Item/45.aspx">遂宁举办首届中国观音...</a><br />
</div>

<div class="pe_u_thumb"><a href="/Item/42.aspx"><img class="pic2" src="http://t11.baidu.com/it/u=549283016,1984989665&fm=0&gp=-36.jpg" width="150" height="150" alt="路透社为“中国体操女团无缘决赛”假新闻致歉" border="0" /></a></div>
<div class="pe_u_thumb_title"><a href="/Item/42.aspx">路透社为“中国体操女...</a><br />
</div>

<div class="pe_u_thumb"><a href="/Item/41.aspx"><img class="pic2" src="http://t11.baidu.com/it/u=4176958180,1616754526&fm=0&gp=6.jpg" width="150" height="150" alt="神舟七号发射成功" border="0" /></a></div>
<div class="pe_u_thumb_title"><a href="/Item/41.aspx">神舟七号发射成功</a><br />
</div>

</div>
<div id="div3" class="div2"></div>
</div>
</div>
</body>
</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: