不间断图片横向滚动特效代码

<html>
<head>
<style>
body{margin:0px;}
ul{list-style:none; border:0; padding:0px; margin:0px;}
li{list-style:none; float:left; border:0; padding:0px; margin:0px;}
img{border:0px;  padding:0px; margin:0px;}
</style>
</head>
<body>
<center><div id="div1" style="overflow:hidden; cursor:hand; margin-top:50px;" οnmοuseοver="stop()" οnmοuseοut="ss()">
           <ul id="img" style="clear:both;"><!--放图片的容器,此容器在div1里滚动-->
        <!--以下是要滚动的内容-->
              <li><img id="img0" src="http://www.alixixi.com/images/index180.gif" width="100" height="100" style="display:block;" /></li>
     <li><img id="img1" src="http://www.alixixi.com/images/index180.gif" width="100" height="100" style="display:block;" /></li>
     <li><img id="img2" src="http://www.alixixi.com/images/index180.gif" width="100" height="100" style="display:block;" /></li>
     <li><img id="img3" src="http://www.alixixi.com/images/index180.gif" width="100" height="100" style="display:block;" /></li>
        </ul>     
</div>
</center>
<script language="javascript">
var w,h,id,speed,Html
w=400;//-------滚动容器的宽度--------//
h=100;//-------滚动容器的高度--------//
id="div1";//-------滚动容器的id--------//
direction="left";//-------滚动方向有四个值left,right,up,down,自己试试--------//
speed="100";//-------滚动速度100相当于1秒,越小越快--------//
imgDiv="img";//-------放图片的容器id--------//
HtmlL=document.getElementById(imgDiv).innerHTML;
HtmlT=document.getElementById(id).innerHTML;
switch (direction)
{
case "left":
     document.getElementById(imgDiv).innerHTML=HtmlL+HtmlL;
  break;
case "right":
     document.getElementById(imgDiv).innerHTML=HtmlL+HtmlL;
  break;
case "up":
     document.getElementById(id).innerHTML=HtmlT+HtmlT;
  break;
case "down":
     document.getElementById(id).innerHTML=HtmlT+HtmlT;
  break;
}
function ss(){
document.getElementById(id).style.width=w;
document.getElementById(id).style.height=h;
document.getElementById(imgDiv).style.width=w*2;
document.getElementById(imgDiv).style.height=h;
var ele
ele=document.getElementById("div1");
switch (direction)
{
case "left":
ele.scrollLeft=ele.scrollLeft+5;
if (ele.scrollLeft>=w)
{
ele.scrollLeft=0;
}
break;
case "right":
ele.scrollLeft=ele.scrollLeft-5;
if (ele.scrollLeft<=0)
{
ele.scrollLeft=w;
}
break;
case "up":
ele.scrollTop=ele.scrollTop+5;
if (ele.scrollTop>=h)
{
ele.scrollTop=0;
}
break;
case "down":
ele.scrollTop=ele.scrollTop-5;
if (ele.scrollTop<=0)
{
ele.scrollTop=h;
}
break;
}
t=setTimeout("ss()",speed);
}
function stop(){
document.getElementById("div1").scrollLeft=document.getElementById("div1").scrollLeft;
document.getElementById("div1").scrollTop=document.getElementById("div1").scrollTop;
     clearTimeout(t);
}
setTimeout("ss()",100);
</script>
</body>
</html>
<a href="http://js.alixixi.com/">欢迎访问阿里西西网页特效代码站,js.alixixi.com</a>


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值