js图片轮播左右滚动
来源:互联网 发布:知秋一生所爱吉他弹唱 编辑:程序博客网 时间:2024/05/21 16:22
#scroll{width:800px; height:150px; margin:10px auto; position:relative;overflow:hidden;}
#scroll ul{position:absolute; left:-16px;; top:-5px;}
#scroll ul li{float:left; width:200px; height:150px; list-style:none; border:#CCC 1px solid;}
#scroll ul li img{width:100%; height:150px;}
window.onload=function(){
var oDiv=document.getElementByIdx_x('scroll');
var oUl=oDiv.getElementsByTagName_r('ul')[0];
var aLi=oUl.getElementsByTagName_r('li');
var Timer=null;
var speed=2;
oUl.innerHTML=oUl.innerHTML+oUl.innerHTML;
oUl.style.width=aLi[0].offsetWidth*aLi.length+'px';
function move(){
if(oUl.offsetLeft<-oUl.offsetWidth/2) //向左滚动
{
oUl.style.left='0';
}
else if(oUl.offsetLeft>0) //向右滚动
{
oUl.style.left=-oUl.offsetWidth/2+'px';
}
//向左滚动
oUl.style.left=oUl.offsetLeft+speed+'px';
}
Timer=setInterval(move,30)
oDiv.onmouseover=function(){ //鼠标点击停止
clearInterval(Timer);
};
oDiv.onmouseout=function(){ //鼠标离开继续
Timer=setInterval(move,30);
}
document.getElementsByTagName_r('a')[0].onclick=function(){
speed=-2;
}
document.getElementsByTagName_r('a')[1].onclick=function(){
speed=2;
}
};
#scroll ul{position:absolute; left:-16px;; top:-5px;}
#scroll ul li{float:left; width:200px; height:150px; list-style:none; border:#CCC 1px solid;}
#scroll ul li img{width:100%; height:150px;}
window.onload=function(){
var oDiv=document.getElementByIdx_x('scroll');
var oUl=oDiv.getElementsByTagName_r('ul')[0];
var aLi=oUl.getElementsByTagName_r('li');
var Timer=null;
var speed=2;
oUl.innerHTML=oUl.innerHTML+oUl.innerHTML;
oUl.style.width=aLi[0].offsetWidth*aLi.length+'px';
function move(){
if(oUl.offsetLeft<-oUl.offsetWidth/2) //向左滚动
{
oUl.style.left='0';
}
else if(oUl.offsetLeft>0) //向右滚动
{
oUl.style.left=-oUl.offsetWidth/2+'px';
}
//向左滚动
oUl.style.left=oUl.offsetLeft+speed+'px';
}
Timer=setInterval(move,30)
oDiv.onmouseover=function(){ //鼠标点击停止
clearInterval(Timer);
};
oDiv.onmouseout=function(){ //鼠标离开继续
Timer=setInterval(move,30);
}
document.getElementsByTagName_r('a')[0].onclick=function(){
speed=-2;
}
document.getElementsByTagName_r('a')[1].onclick=function(){
speed=2;
}
};
0 0
- js图片轮播左右滚动
- js图片轮播滚动
- js实现图片左右移动轮播
- js图片左右滚动
- 图片左右轮播
- Js图片连续左右滚动
- js图片左右无缝滚动
- 带左右箭头图片轮播的JS代码
- js实现图片左右轮播(一)
- 图片轮播/滚动
- js左右轮播代码
- js实现图片的无缝轮播滚动
- JS浏览图片,左右滚动效果
- js实现图片左右循环滚动
- JS无缝图片滚动(上下,左右)
- js控制图片左右滚动,自动翻滚,图片滚动展示
- Android 图片轮播,图片左右自动滚动与页面侧滑菜单冲突,请问怎么解决?
- js图片轮播
- js元素完美拖拽效果
- 1.2.0 Quickstart: "Hello World"(快速开始:“你好世界!”)
- cocos2d-x源码
- 在 artDialog 窗口中追加最大化、最小化按钮
- Markdoen语法
- js图片轮播左右滚动
- C#程序提示”遇到问题正在关闭“的问题,并且没有日志输出
- 逐浪粗宋字体初次感觉体验上手印象
- php+croppic 图片裁剪,可缩放、旋转
- dpkg: warning: files list file for package `*’ missing 解决方法
- 机器视觉 Local Binary Pattern (LBP)
- mysql varchar 类型 日期查询范围
- SQL Server xtype的介绍
- #define new DEBUG_NEW