左右无间断滚动
作者:佚名 | 来源:雪幕天涯 | 时间:2008-11-26 | 阅读权限:游客 | 会员币:0 | 【
大 中 小】
以下是代码片段:
<!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:#CCCCCC;
height:20px;
overflow:hidden;
white-space:nowrap;
}
.d2{
margin:0px auto;
background-color:#FF9933;
}
.div2{
width:auto;
height:20px;
font-size:12px;
}
</style>
<script language="javascript" type="text/javascript">
var s,s2,s3,timer;
function init(){
s=getid("div1");
s2=getid("div2");
s3=getid("div3");
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)">
<span class="div2" id="div2"> [系统相关] Windows清理助手 V2.8.34.8.1123(1513)绿色版 [媒体工具] Nero Burning Rom 9.0.9.4d简体中文绿色精简版 [视频播放] 摄像头录像大师 6.4 [原名:摄像头录像机] [系统相关] Windows优化大师破解版V7.807 绿色去广告专业版 </span><span id="div3" class="div2"></span>
</div>
</body>
</html>
相关评论(以下网友评论只代表其个人观点,不代表【雪幕天涯】的观点或立场)