标题:划动效果
只看楼主
史诺比
Rank: 1
等 级:新手上路
帖 子:169
专家分:0
注 册:2007-10-12
 问题点数:0 回复次数:1 
划动效果

<html><head><title></title>
<style>
#aa1{width:200px;height:50px;overflow:hidden;border:1px solid red;}
#aa2{width:600px;height:50px;background:red}
#aa2 div{width:100px;height:40px;margin:5px 0px 5px 0px;background:#fff;float:left}
</style>

<script language="javascript">
var abc=1
function aa(){
if(aa1.scrollLeft>=aa2.offsetWidth/2 && abc>0){aa1.scrollLeft=0}
if(aa1.scrollLeft==0 && abc<0){aa1.scrollLeft=aa2.offsetWidth/2}
aa1.scrollLeft+=abc;
setTimeout("aa()",50)
}
</script>
</head><body onload="aa()">
<div id="aa1">
<div id="aa2">
<div>1111111111111111</div>
<div>2222222222222222</div>
<div>3333333333333333</div>
<div>1111111111111111</div>
<div>2222222222222222</div>
</div>

</div>
<button onclick="javascript:abc=1"><<<<<<</button>
<button onclick="javascript:abc=-1">>>>>>></button>
</body></html>

以经被我精简的不能再精简了,相信初学者都看的懂了
搜索更多相关主题的帖子: 效果 
2007-10-13 17:33
史诺比
Rank: 1
等 级:新手上路
帖 子:169
专家分:0
注 册:2007-10-12
得分:0 

[QUOTE]<html><head><title></title>
<style>
#aa1{width:200px;height:100px;overflow:hidden;border:1px solid red;}
#aa2{width:600px;height:325px;background:red}
#aa2 div{width:190px;height:50px;margin:4px 4px 4px 4px;background:#fff;}
</style>
<script language="javascript">
var abc=1
function aa(){
if(aa1.scrollTop>=aa2.offsetHeight/2 && abc>0){aa1.scrollTop=0}
if(aa1.scrollTop==0 && abc<0){aa1.scrollTop=aa2.offsetHeight/2}
aa1.scrollTop+=abc;
setTimeout("aa()",50)
}
</script>
</head>
<body onload="aa()">
<div id="aa1">
<div id="aa2">
<div>1111111111111111</div>
<div>2222222222222222</div>
<div>3333333333333333</div>
<div>1111111111111111</div>
<div>2222222222222222</div>
</div>
</div>
<button onclick="javascript:abc=1">上</button>
<button onclick="javascript:abc=-1">下</button>
</body></html>[/QUOTE]


2007-10-13 17:53



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-177329-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 1.106888 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved