导航:首页 > 好看图片 > 简单的jquery图片轮播

简单的jquery图片轮播

发布时间:2023-03-03 17:00:50

1. 用JQuery实现一行多图轮播,是单击一下一张图片轮播,不是一下一行图片轮播,给个例子,跪求


<!doctypehtml>
<html>
<head>
<metacharset="UTF-8">
<title>Document</title>
<style>
*{padding:0;margin:0;}
ulli{list-style-type:none}
.gameTab{width:1100px;height:150px;overflow:hidden;margin:50pxauto;position:relative;}
.gameTabul{width:7680px;overflow:hidden;}
.gameTabul>li{width:220px;height:150px;float:left;text-align:center;}
.gameTabul>li:hover{opacity:0.5}
.prev,.next{position:absolute;top:50%;transform:translate(0,-50%);padding:5px;background:red;z-index:99;text-decoration:none;color:#fff;

}
.prev{left:0;}
.next{right:0;}
</style>
</head>
<body>
<div>
<ahref="javascript:;">前一张</a>
<ul>
<listyle="background:#CB2929">1111</li>
<listyle="background:#23C048">2222</li>
<listyle="background:#00ABEA">3333</li>
<listyle="background:#FF9800">4444</li>
<listyle="background:#F96B36">5555</li>
<listyle="background:#ADADAD">6666</li>
</ul>
<ahref="javascript:;">下一张</a>
</div>
<scriptsrc="http://code.jquery.com/jquery-2.1.1.min.js"></script>
<script>
$(function(){
//下一张
functionmoveLeft(){
$(".gameTabul").animate({marginLeft:"-220px"},300,function(){
$(".gameTabul").children().first().appendTo($(".gameTabul"));
$(".gameTabul").css('marginLeft','0px');
});
}
$('.next').click(moveLeft);

//前一张
$('.prev').click(function(){
$(".gameTabul").children().last().prependTo($(".gameTabul"));//把ul的最后一个子元素添加到开头第一个
$(".gameTabul").css('marginLeft','-220px');//初始化把ul的marginleft左移220
$(".gameTabul").animate({marginLeft:"0px"},300);

})

//自动轮播
vartimer=setInterval(moveLeft,3000)

//hover时停掉定时器
$('.gameTab').mouseenter(function(){
clearTimeout(timer)
})
$('.gameTab').mouseleave(function(){
timer=setInterval(moveLeft,3000)
})
})
</script>
</body>
</html>

2. jquery图片上下轮播的问题,怎么实现自动轮播

1、html部分

<body>
<divid="banner">
<divid="banner_bg"></div><!--标题背景-->
<divid="banner_info"></div><!--标题-->
<ul>
<liclass="on">1</li>
<li>2</li>
<li>3</li>
<li>4</li>
</ul>
<divid="banner_list">
<ahref="#"target="_blank"><imgsrc="imgs/p1.jpg"title="橡树小屋的blog"alt="橡树小屋的blog"/></a>
<ahref="#"target="_blank"><imgsrc="imgs/p5.jpg"title="橡树小屋的blog"alt="橡树小屋的blog"/></a>
<ahref="#"target="_blank"><imgsrc="imgs/p3.jpg"title="橡树小屋的blog"alt="橡树小屋的blog"/></a>
<ahref="#"target="_blank"><imgsrc="imgs/p4.jpg"title="橡树小屋的blog"alt="橡树小屋的blog"/></a>
</div>
</div>
</body>


2、css样式部分

<styletype="text/css">

#banner{position:relative;width:478px;height:286px;border:1pxsolid#666;overflow:hidden;}
#banner_listimg{border:0px;}
#banner_bg{position:absolute;bottom:0;background-color:#000;height:30px;filter:Alpha(Opacity=30);opacity:0.3;z-index:1000;
cursor:pointer;width:478px;}
#banner_info{position:absolute;bottom:0;left:5px;height:22px;color:#fff;z-index:1001;cursor:pointer}
#banner_text{position:absolute;width:120px;z-index:1002;right:3px;bottom:3px;}
#bannerul{position:absolute;list-style-type:none;filter:Alpha(Opacity=80);opacity:0.8;border:1pxsolid#fff;z-index:1002;
margin:0;padding:0;bottom:3px;right:5px;}
#bannerulli{padding:0px8px;float:left;display:block;color:#FFF;border:#e5eaff1pxsolid;background:#6f4f67;cursor:pointer}
#bannerulli.on{background:#900}
#banner_lista{position:absolute;}<!--让四张图片都可以重叠在一起-->
</style>


3、jQuery部分

<scripttype="text/javascript">
vart=n=0,count;
$(document).ready(function(){
count=$("#banner_lista").length;
$("#banner_lista:not(:first-child)").hide();
$("#banner_info").html($("#banner_lista:first-child").find("img").attr('alt'));
$("#banner_info").click(function(){window.open($("#banner_lista:first-child").attr('href'),"_blank")});
$("#bannerli").click(function(){
vari=$(this).text()-1;//获取Li元素内的值,即1,2,3,4
n=i;
if(i>=count)return;
$("#banner_info").html($("#banner_lista").eq(i).find("img").attr('alt'));
$("#banner_info").unbind().click(function(){window.open($("#banner_lista").eq(i).attr('href'),"_blank")})
$("#banner_lista").filter(":visible").fadeOut(500).parent().children().eq(i).fadeIn(1000);
document.getElementById("banner").style.background="";
$(this).toggleClass("on");
$(this).siblings().removeAttr("class");
});
t=setInterval("showAuto()",4000);
$("#banner").hover(function(){clearInterval(t)},function(){t=setInterval("showAuto()",4000);});
})

functionshowAuto()
{
n=n>=(count-1)?0:++n;
$("#bannerli").eq(n).trigger('click');
}
</script>

3. jquery图片自动轮播怎么设置求高手

<!DOCTYPEHTML>
<html>
<head>
<title>yugi</title>
<metacharset=UTF-8/>
<styletype="text/css">
#pic{
width:410px;
height:200px;
margin:0auto;
margin-top:150px;
}

#pic#po{
width:370px;
overflow:hidden;
height:170px;
left:20px;;
top:10;
position:relative;
}

#pic#pol{
width:2370px;
height:165px;
position:absolute;
}

#pic#num{
width:120px;
height:25px;
position:absolute;
z-index:2;
left:247px;
top:140px;
}

#pic#numspan{
width:10px;
margin-left:10px;
cursor:pointer;
font-size:12px;
height:20px;
float:left;
color:#000000;
text-align:center;
}

#pic#numspan.cut{
background:#000000;
color:#FFFFFF;
}

img{
width:370px;
height:165px;
float:left
}
</style>
<scripttype="text/javascript"src="jquery-1.8.0.min.js"></script>
<scripttype="text/javascript">
jQuery(function($)
{
varCRT=0;
varw=$("img").width(),pol=$("#pol"),spans=$("#numspan");
spans.hover(function()
{
varme=$(this);
me.addClass("cut").siblings(".cut").removeClass("cut");
spans.eq(CRT).clearQueue();
pol.stop().animate(
{
left:"-"+w*(CRT=me.index())+"px"
},"slow");
},function()
{
anony();
});

varanony=function()
{
CRT++;
CRT=CRT>spans.length-1?0:CRT;
spans.eq(CRT).clearQueue().delay(1000).queue(function()
{
spans.eq(CRT).triggerHandler("mouseover");
anony();
});
};

anony();
});
</script>
</head>
<body>
<divid="pic">
<divid="po">
<divid="pol">
<imgsrc="../../图片/素材/.jpg"/>
<imgsrc="../../图片/素材/.jpg"/>
<imgsrc="../../图片/素材/.jpg"/>
<imgsrc="../../图片/素材/.jpg"/>
<imgsrc="../../图片/素材/.jpg"/>
</div>
<divid="num">
<spanclass="cut">1</span>
<span>2</span>
<span>3</span>
<span>4</span>
<span>5</span>
</div>
</div>
</div>
</body>
</html>

4. 求JQUERY的图片左右轮播的代码,要简单一点的谢谢

首先要定义一个索引来表示你当前轮播到第几张图片了
然后获得你总共有几张图片 当索引跳到最后一张的时候 将其值改为0 即可
对于上一页下一页 逻辑与上面相同
如果当前索引为0 或者为最后一个隐藏掉这个按钮或者赋值另一端的极值
轮播的话 写一个定时器 第一个参数就是这个函数啦 第二个参数给1000(ms)
函数里面就对这个index按上面的逻辑操作即可了
思路给你了 自己写吧。。边查边写 收获会很大

5. jquery简单自动轮播图代码怎么写

html部分           this is the page一     this is the page二     this is the page三     this is the page四          css部分 *{     padding: 0;     margin: 0;     }     html,body{     height: 一00%;     }     #container {     width: 一00%;     height: 500px;     overflow: hidden;     }     .sections,.section {     height:一00%;     }     #container,.sections {     position: relative;     }     .section {     background-color: #000;     background-size: cover;     background-position: 50% 50%;     text-align: center;     color: white;     }     #section0 {     background-image: url('images/一.jpg');     }     #section一 {     background-image: url('images/二.jpg');     }     #section二 {     background-image: url('images/三.jpg');     }     #section三 {     background-image: url('images/四.jpg');     }   .pages li{list-style-type:none;width:一0px;height:一0px;border-radius:一0px;background-color:white}.pages li:hover{box-shadow:0 0 5px 二px white}.pages li.active{background-color:orange;box-shadow:0 0 5px 二px orange}.pages{position:absolute;z-index:999}.pages.horizontal{left:50%;transform:translateX(-50%);bottom:5px}.pages.horizontal li{display:inline-block;margin-right:一0px}.pages.horizontal li:last-child{margin-right:0}.pages.vertical{right:5px;top:50%;transform:translateY(-50%)}.pages.vertical li{margin-bottom:一0px}.pages.vertical li:last-child{margin-bottom:0} JS部分 jquery-一.一一.0.min.js" type="text/javascript"> //引入pageSwitch.min.js 如

6. 用jquery实现图片轮播怎么写呢求指教

*{
margin:0;
padding:0;
}
ul{
list-style:none;
}
.slideShow{
width:620px;
height:700px;/*其实就是图片的高度*/
border:1px#eeeeeesolid;
margin:100pxauto;
position:relative;
overflow:hidden;/*此处需要将溢出框架的图片部分隐藏*/
}
.slideShowul{
width:2500px;
position:relative;/*此处需注意relative:对象不可层叠,但将依据left,right,top,bottom等属性在正常文档流中偏移位置,如果没有这个属性,图片将不可左右移动*/
}
.slideShowulli{
float:left;/*让四张图片左浮动,形成并排的横着布局,方便点击按钮时的左移动*/
width:620px;
}
.slideShow.showNav{/*用绝对定位给数字按钮进行布局*/
position:absolute;
right:10px;
bottom:5px;
text-align:center;
font-size:12px;
line-height:20px;
}
.slideShow.showNavspan{
cursor:pointer;
display:block;
float:left;
width:20px;
height:20px;
background:#ff5a28;
margin-left:2px;
color:#fff;
}
.slideShow.showNav.active{
background:#b63e1a;
}

js代码规范:
<scriptsrc="../../../jQuery/js/jquery-2.1.4.js"></script><scripttype="text/javascript">

$(document).ready(function(){

varslideShow=$(".slideShow"),//获取最外层框架的名称

ul=slideShow.find("ul"),

showNumber=slideShow.find(".showNavspan"),//获取按钮

oneWidth=slideShow.find("ulli").eq(0).width();//获取每个图片的宽度

vartimer=null;//定时器返回值,主要用于关闭定时器

variNow=0;//iNow为正在展示的图片索引值,当用户打开网页时首先显示第一张图,即索引值为0

showNumber.on("click",function(){//为每个按钮绑定一个点击事件

$(this).addClass("active").siblings().removeClass("active");//按钮点击时为这个按钮添加高亮状态,并且将其他按钮高亮状态去掉

varindex=$(this).index();//获取哪个按钮被点击,也就是找到被点击按钮的索引值

iNow=index;

ul.animate({"left":-oneWidth*iNow,//注意此处用到left属性,所以ul的样式里面需要设置position:relative;让ul左移N个图片大小的宽度,N根据被点击的按钮索引值iNOWx确定

})

});

functionautoplay(){

timer=setInterval(function(){//打开定时器

iNow++;//让图片的索引值次序加1,这样就可以实现顺序轮播图片

if(iNow>showNumber.length-1){//当到达最后一张图的时候,让iNow赋值为第一张图的索引值,轮播效果跳转到第一张图重新开始

iNow=0;}

showNumber.eq(iNow).trigger("click");//模拟触发数字按钮的click

},2000);//2000为轮播的时间

}

autoplay();

slideShow.hover(function(){clearInterval(timer);},autoplay);另外注意setInterval的用法比较关键。

})

</script>

主体代码:
[html]viewplainprint?
<body>
<divclass="slideShow">
<!--图片布局开始-->
<ul>
<li><ahref="#"><imgsrc="images/view/111.jpg"/></a></li>
<li><ahref="#"><imgsrc="images/view/112.jpg"/></a></li>
<li><ahref="#"><imgsrc="images/view/113.jpg"/></a></li>
<li><ahref="#"><imgsrc="images/view/114.jpg"/></a></li>
</ul>
<!--图片布局结束-->

<!--按钮布局开始-->
<divclass="showNav">
<spanclass="active">1</span>
<span>2</span>
<span>3</span>
<span>4</span>
</div>
<!--按钮布局结束-->
</div>

</body>

阅读全文

与简单的jquery图片轮播相关的资料

热点内容
心痛女孩子的动态图片 浏览:191
女孩白色内内图片 浏览:204
入冬早上好文字图片 浏览:618
帅气男生换装图片 浏览:216
短发面条卷发型图片 浏览:1002
可爱小孩子图片卖萌 浏览:638
花的图画手绘简单图片 浏览:772
动漫公主服装图片大全图片大全 浏览:174
动漫绘画作品图片 浏览:128
小女孩几几的现状图片 浏览:299
樱花图片动漫图 浏览:743
成熟潮男搭配衣服图片 浏览:170
动漫人物图片大全黑白 浏览:1089
最多动漫图片 浏览:845
小鸟衣服图片大全可爱 浏览:510
手挡太阳的图片女生 浏览:556
男女生图片背影图片 浏览:1091
想太多心会累文字图片 浏览:434
简单动漫图片教程视频 浏览:623
女孩发育图片视频 浏览:622