图片横向移动
2009-05-07 11:21
302 查看
<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>
<a href="http://js.alixixi.com/">欢迎访问阿里西西网页特效代码站,js.alixixi.com</a>
<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>
<a href="http://js.alixixi.com/">欢迎访问阿里西西网页特效代码站,js.alixixi.com</a>
相关文章推荐
- jquery实现图片横向移动
- 鼠标经过箭头时,图片会向左或向右横向移动
- JavaScript实现图片横向移动(转载)
- 在移动平台上使用tensorflow图片分类 (android and ios)
- android 图片横向滚动效果 原创【安卓进化五】
- ASP.Net中无法用javascript实现图片随屏幕移动的解决办法
- 博客技巧-图片链接移动代码
- Wpf图片变换一:通过WPF实现图片的扩大、缩小、翻转、移动实例代码
- jquery实现:提示文本/图片跟随鼠标移动
- 解决PHP move_uploaded_file函数移动图片失败
- JS 横向图片跑马灯效果
- html跑马灯代码大全(图片文字移动代码)
- 纯CSS实现鼠标移动切换图片示例
- java图片插入窗口定时循环移动或者按鼠标位置移动
- 图片旋转移动的效果
- dedecms横向滚动图片
- ubuntu 图片移动命令
- 解决页面滚动条出现和消失的过程页面会横向移动的问题
- 使用InvalidateRect(rect) 防止图片移动时发生闪烁
- jquery横向图片滚动