不间断图片横向滚动特效代码
2009-01-07 10:44
435 查看
<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;" onmouseover="stop()" onmouseout="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>
<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;" onmouseover="stop()" onmouseout="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>
相关文章推荐
- 不间断图片横向滚动特效代码
- 图片横向不间断滚动代码(div+css)
- JS特效代码大全(六)图片横向滚动效果
- JS特效之连续不断横向滚动图片代码
- 连续不间断横向滚动图片代码
- 连续不间断横向滚动图片代码
- JS特效代码大全(六)图片横向滚动效果
- --连续不间断横向滚动图片代码--
- 连续不间断横向滚动图片代码
- 图片不间断滚动的特效代码详细讲解
- 2个按钮控制的左右图片滚动特效代码
- 图片滚动代码横向按钮控制
- 连续不间断横向滚动图片
- JS图片横向滚动的代码
- DIV+CSS+JS实现不间断横向滚动代码
- JS图片不间断滚动代码
- Js图片滚动代码,横向纵向滚动,面向对象代码
- js图片不间断滚动代码(向上,向下,向左,向右)
- div+css+jQuery图片横向滚动代码(带左右点击按钮)
- JavaScript特效:横向不间断滚动