Asp学习站欢迎你!

非常实用的DIV+Js实现图片向上滚动效果

作者:Admin 时间:08-05-24 点击:

收集了一款“非常实用的DIV+Js实现图片向上滚动效果”,希望大家能用的上。

效果请参阅:http://www.inwu114.cn/blog/download/test/

index.asp

<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!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=gb2312" />
<title>图片滚动效果</title>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>

<body>
<SCRIPT language=JavaScript src="playfandong.js" type=text/javascript></SCRIPT>
<div id="info">
<div><img src="http://www.inwu114.cn/blog/wp-content/uploads/2008/04/info.jpg"></div>
<div><img src="http://www.inwu114.cn/blog/wp-content/uploads/2008/04/mail.jpg"></div>
<div><img src="http://www.inwu114.cn/blog/wp-content/uploads/2008/04/link.jpg"></div>
</div>
</body>
</html>

 

style.css/* CSS Document */
body{ width:80%; margin:0; padding:0;}
#info { margin:100px auto;
FONT-SIZE: 12px; OVERFLOW: hidden; WIDTH: 740px; COLOR: #66CCCC; HEIGHT: 100px;}
#info DIV {
OVERFLOW: hidden; LINE-HEIGHT: 100px; WHITE-SPACE: nowrap; HEIGHT: 100px; float:left;
}
 

playfandong.js

var tc;
window.onload=function(){
var o=document.getElementById(’info’);hscroll(o);
window.setInterval(function(){window.clearTimeout(tc);o.firstChild.style.marginLeft=’0px’;scrollup(o,100,0);},9000);//修改100控制div高度,修改9000控制间隙时间
}
function scrollup(o,d,c){
if(d==c){
var t=o.firstChild.cloneNode(true);
o.removeChild(o.firstChild);o.appendChild(t);
t.style.marginTop=o.firstChild.style.marginTop=’0px’;
hscroll(o);
}
else{
ch=false;var s=3,c=c+s,l=(c>=d?c-d:0);
o.firstChild.style.marginTop=-c+l+’px’;
window.setTimeout(function(){scrollup(o,d,c-l)},50);
}
}

function hscroll(o){
var w1=o.firstChild.offsetWidth,w2=o.offsetWidth;
if(w1<=w2)return;
tc=window.setTimeout(function(){hs(o,w1-w2,0,w1-w2)},3500);
}

function hs(o,d,c,p){
c++;var t=(c>0?-c:c);o.firstChild.style.marginLeft=t+’px’;
if(c==d){if(d==0){tc=window.setTimeout(function(){hs(o,p,0,p)},2500);}else tc=window.setTimeout(function(){hs(o,0,-p,p)},3500);}
else tc=window.setTimeout(function(){hs(o,d,c,p)},5);
}
 

最新评论共有 0 位网友发表了评论
发表评论
评论内容:不能超过250字,需审核,请自觉遵守互联网相关政策法规。
用户名: 验证码: 验证码 查看所有评论