首先引入js,内容如下:

 (function($){$.fn.slides=function(option){option=$.extend({},$.fn.slides.option,option);return this.each(function(){$('.'+option.container,$(this)).children().wrapAll('<div class="slides_control"/>');var elem=$(this),control=$('.slides_control',elem),total=control.children().size(),width=control.children().outerWidth(),height=control.children().outerHeight(),start=option.start-1,effect=option.effect.indexOf(',')<0?option.effect:option.effect.replace(' ','').split(',')[0],paginationEffect=option.effect.indexOf(',')<0?effect:option.effect.replace(' ','').split(',')[1],next=0,prev=0,number=0,current=0,loaded,active,clicked,position,direction;if(total<2){return;}
if(start<0){start=0;};if(start>total){start=total-1;};if(option.start){current=start;};if(option.randomize){control.randomize();}
$('.'+option.container,elem).css({overflow:'hidden',position:'relative'});control.css({position:'relative',width:(width*3),height:height,left:-width});control.children().css({position:'absolute',top:0,left:width,zIndex:0,display:'none'});if(option.autoHeight){control.animate({height:control.children(':eq('+start+')').outerHeight()},option.autoHeightSpeed);}
if(option.preload&&control.children()[0].tagName=='IMG'){elem.css({background:'url('+option.preloadImage+') no-repeat 50% 50%'});var img=$('img:eq('+start+')',elem).attr('src')+'?'+(new Date()).getTime();$('img:eq('+start+')',elem).attr('src',img).load(function(){$(this).fadeIn(option.fadeSpeed,function(){$(this).css({zIndex:5});elem.css({background:''});loaded=true;});});}else{control.children(':eq('+start+')').fadeIn(option.fadeSpeed,function(){loaded=true;});}
if(option.bigTarget){control.children().css({cursor:'pointer'});control.children().click(function(){animate('next',effect);return false;});}
if(option.hoverPause&&option.play){control.children().bind('mouseover',function(){stop();});control.children().bind('mouseleave',function(){pause();});}
if(option.generateNextPrev){$('.'+option.container,elem).after('<a href="#" class="'+option.prev+'">Prev</a>');$('.'+option.prev,elem).after('<a href="#" class="'+option.next+'">Next</a>');}
$('.'+option.next,elem).click(function(e){e.preventDefault();if(option.play){pause();};animate('next',effect);});$('.'+option.prev,elem).click(function(e){e.preventDefault();if(option.play){pause();};animate('prev',effect);});if(option.generatePagination){elem.append('<ul class='+option.paginationClass+'></ul>');control.children().each(function(){$('.'+option.paginationClass,elem).append('<li><a rel='+number+' href="#">'+(number+1)+'</a></li>');number++;});}else{$('.'+option.paginationClass+' li a',elem).each(function(){$(this).attr('rel',number);number++;});}
$('.'+option.paginationClass+' li a:eq('+start+')',elem).parent().addClass('current');$('.'+option.paginationClass+' li a',elem).click(function(){if(option.play){pause();};clicked=$(this).attr('rel');if(current!=clicked){animate('pagination',paginationEffect,clicked);}
return false;});if(option.play){playInterval=setInterval(function(){animate('next',effect);},option.play);elem.data('interval',playInterval);};function stop(){clearInterval(elem.data('interval'));};function pause(){if(option.pause){clearTimeout(elem.data('pause'));clearInterval(elem.data('interval'));pauseTimeout=setTimeout(function(){clearTimeout(elem.data('pause'));playInterval=setInterval(function(){animate("next",effect);},option.play);elem.data('interval',playInterval);},option.pause);elem.data('pause',pauseTimeout);}else{stop();}};function animate(direction,effect,clicked){if(!active&&loaded){active=true;switch(direction){case'next':prev=current;next=current+1;next=total===next?0:next;position=width*2;direction=-width*2;current=next;break;case'prev':prev=current;next=current-1;next=next===-1?total-1:next;position=0;direction=0;current=next;break;case'pagination':next=parseInt(clicked,10);prev=$('.'+option.paginationClass+' li.current a',elem).attr('rel');if(next>prev){position=width*2;direction=-width*2;}else{position=0;direction=0;}
current=next;break;}
if(effect==='fade'){option.animationStart();if(option.crossfade){control.children(':eq('+next+')',elem).css({zIndex:10}).fadeIn(option.fadeSpeed,function(){control.children(':eq('+prev+')',elem).css({display:'none',zIndex:0});$(this).css({zIndex:0});option.animationComplete(next+1);active=false;});}else{option.animationStart();control.children(':eq('+prev+')',elem).fadeOut(option.fadeSpeed,function(){if(option.autoHeight){control.animate({height:control.children(':eq('+next+')',elem).outerHeight()},option.autoHeightSpeed,function(){control.children(':eq('+next+')',elem).fadeIn(option.fadeSpeed);});}else{control.children(':eq('+next+')',elem).fadeIn(option.fadeSpeed,function(){if($.browser.msie){$(this).get(0).style.removeAttribute('filter');}});}
option.animationComplete(next+1);active=false;});}}else{control.children(':eq('+next+')').css({left:position,display:'block'});if(option.autoHeight){option.animationStart();control.animate({left:direction,height:control.children(':eq('+next+')').outerHeight()},option.slideSpeed,function(){control.css({left:-width});control.children(':eq('+next+')').css({left:width,zIndex:5});control.children(':eq('+prev+')').css({left:width,display:'none',zIndex:0});option.animationComplete(next+1);active=false;});}else{option.animationStart();control.animate({left:direction},option.slideSpeed,function(){control.css({left:-width});control.children(':eq('+next+')').css({left:width,zIndex:5});control.children(':eq('+prev+')').css({left:width,display:'none',zIndex:0});option.animationComplete(next+1);active=false;});}}
if(option.pagination){$('.'+option.paginationClass+' li.current',elem).removeClass('current');$('.'+option.paginationClass+' li a:eq('+next+')',elem).parent().addClass('current');}}};});};$.fn.slides.option={preload:false,preloadImage:'/img/loading.gif',container:'slides_container',generateNextPrev:false,next:'next',prev:'prev',pagination:true,generatePagination:true,paginationClass:'pagination',fadeSpeed:350,slideSpeed:350,start:1,effect:'slide',crossfade:false,randomize:false,play:0,pause:0,hoverPause:false,autoHeight:false,autoHeightSpeed:350,bigTarget:false,animationStart:function(){},animationComplete:function(){}};$.fn.randomize=function(callback){function randomizeOrder(){return(Math.round(Math.random())-0.5);}
return($(this).each(function(){var $this=$(this);var $children=$this.children();var childCount=$children.length;if(childCount>1){$children.hide();var indices=[];for(i=0;i<childCount;i++){indices[indices.length]=i;}
indices=indices.sort(randomizeOrder);$.each(indices,function(j,k){var $child=$children.eq(k);var $clone=$child.clone(true);$clone.show().appendTo($this);if(callback!==undefined){callback($child,$clone);}
$child.remove();});}}));};})(jQuery);

其次html代码:

 <div id="container-img">
<div id="example"> <div id="slides">
<div class="info" title=""></div>
<div class="slides_container">
<a href="" title="" ><img src="__ROOT__/Public/showimages/img/slide-1.jpg" width="570" height="270" alt="1"></a>
<a href="" title="" ><img src="__ROOT__/Public/showimages/img/slide-2.jpg" width="570" height="270" alt="2"></a>
<a href="" title="" ><img src="__ROOT__/Public/showimages/img/slide-3.jpg" width="570" height="270" alt="3"></a>
<a href="" title="" ><img src="__ROOT__/Public/showimages/img/slide-4.jpg" width="570" height="270" alt="4"></a>
<a href="" title="" ><img src="__ROOT__/Public/showimages/img/slide-5.jpg" width="570" height="270" alt="5"></a>
</div>
<a href="#" class="prev"><img src="__ROOT__/Public/showimages/img/arrow-prev.png" width="24" height="43" alt="Arrow Prev"></a>
<a href="#" class="next"><img src="__ROOT__/Public/showimages/img/arrow-next.png" width="24" height="43" alt="Arrow Next"></a>
</div>

然后上css:

 /*
Resets defualt browser settings
reset.css
*/
html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,font,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td { margin:; padding:; border:; outline:; font-weight:inherit; font-style:inherit; font-size:100%; font-family:inherit; vertical-align:baseline; }
:focus { outline:; }
a:active { outline:none; }
body {font-family: '微软雅黑'; font-size: 14px;}
ol,ul { list-style:none; }
table { border-collapse:separate; border-spacing:; }
caption,th,td { text-align:left; font-weight:normal; }
blockquote:before,blockquote:after,q:before,q:after { content:""; }
blockquote,q { quotes:"" ""; } #container {
width:400px;
padding:0px;
margin:0 auto;
position:relative;
z-index:;
} #example {
width:400px;
height:270px;
position:relative;
} #ribbon {
position:absolute;
top:-3px;
left:-3px;
z-index:;
} #frame {
position:absolute;
z-index:;
width:450px;
height:341px;
top:-3px;
left:00px;
} #slides {
position:absolute;
top:0px;
left:0px;
z-index:;
} #slides .next,#slides .prev {
position:absolute;
top:107px;
left:0px;
width:24px;
height:43px;
display: none; }
#slides .next:hover,#slides .prev:hover{
display: block!important;
z-index:;
}
.slides_show{
display: block!important;
z-index:;
} .slides_container {
width:400px;
height:270px;
overflow:hidden;
position:relative;
box-shadow: 0 0 10px #888;
}
.slides_container a:hover{opacity:;}
.info{text-indent: 2em;position: absolute; width: 400px;margin-top: 270px;height: 50px;transition:background 1s,margin-top 0.5s,font-size 0.2s;z-index:;}
.info:hover{margin-top: 230px;color: #fff;}
.infoadd{background: rgba(0, 0, 0, 0.2) !important; /* IE无效,FF有效 */ background: #fff;color: #fff;text-shadow:0 0 1px #888; filter: alpha(opacity=60);margin-top: 230px;display:inline;}
#slides .next {
left:375px; } .pagination {
margin:0px auto 0;
width:100px; } .pagination li {
float:left;
margin:0 1px;
} .pagination li a {
display:block;
width:12px;
height:;
padding-top:12px;
background-image:url(../img/pagination.png);
background-position:0 0;
float:left;
overflow:hidden;
} .pagination li.current a {
background-position:0 -12px;
} a:link,a:visited {
color:#599100;
text-decoration:none;
} a:hover,a:active {
color:#599100;
}

最后加上jq鼠标经过图像显示文字效果:

 $(function(){
$('#slides').slides({
preload: true,
preloadImage: 'img/loading.gif',
play: 5000,
pause: 2500,
hoverPause: true
}); setInterval('change()',100);
$(".slides_container").find('img').live('mouseover',function(){
b=$(this).attr('alt');
$('.info').addClass('infoadd');
$('.next').addClass('slides_show');
$('.prev').addClass('slides_show');
//alert(r);
$(this).attr('title',text); })
$(".slides_container").find('img').live('mouseout',function(){
$(".info").removeClass('infoadd');
$('.next').removeClass('slides_show');
$('.prev').removeClass('slides_show');
}); });
function change(){
var r=$(".current").find("a").attr('rel');
if(r==0){$('.info').text('如果能让我重新在来一次,我希望不曾出现在你的生命里。这对我来说已经来不及了,因为我已经无法自拔');}
if(r==1){$('.info').text('22222');}
if(r==2){$('.info').text('33333');}
if(r==3){$('.info').text('44444');}
if(r==4){$('.info').text('55555');}
}

完工!

jq图片切换特效的更多相关文章

  1. jQuery旋转木马仿3D效果的图片切换特效代码

    用jQuery实现的一款仿3D效果的图片切换特效代码,类似旋转木马一样,幻灯图片以三维视觉上下滑动切换,效果很酷炫,兼容IE8.360.FireFox.Chrome.Safari.Opera.傲游.搜 ...

  2. Winform下实现图片切换特效的方法

    本文实例讲述了Winform下实现图片切换特效的方法,是应用程序开发中非常实用的一个功能.分享给大家供大家参考之用.具体方法如下: 本实例源自网络,功能较为齐全.丰富!主要功能代码如下: using ...

  3. 基于HTML5 SVG和CSS3炫酷蹦床式图片切换特效

    今天给大家分享一款效果非常炫酷的HTML5 SVG和CSS3蹦床式图片切换特效插件.该图片切换插件在进行图片切换时,整个屏幕就像一张大蹦床一样,将图片弹射出去,切换到另一张图片,效果非常有创意.效果图 ...

  4. 一款基于jquery超炫的图片切换特效

    今天为给大家介绍一款基于jquery超炫的图片切换特效.由百叶窗飞入显示图片.图片消息的时候也是百叶窗渐行渐远.用于图片展示,效果还是非常好,我们一起看下效果图: 在线预览   源码下载 来看下实现的 ...

  5. css3全屏背景图片切换特效

    效果体验:http://hovertree.com/texiao/css3/10/ 一般做图片切换效果,都会使用JS或者jQuery脚本,今天发现,其实只用CSS也可以实现.试试效果吧. 效果图: 代 ...

  6. JS组件系列——图片切换特效:简易抽奖系统

    前言:前两天在网上找组件,无意中发现了我们儿时游戏机效果的“SlotMachine组件”,浏览一遍下来,勾起了博主小时候满满的回忆.于是下定决定要研究下这么一个东西,不得不再次叹息开源社区的强大,原来 ...

  7. ES6实现图片切换特效

    效果图 demo.html <!DOCTYPE html> <html lang="en"> <head> <meta charset=& ...

  8. javascript马赛克遮罩图片切换效果:XMosaic.js(转)

    新鲜出炉的javascript图片切换特效,实现的是马赛克遮罩切换.在flash里,好实现遮罩动画很简单,不过JS实现起来就有些困难了. XMosaic.js,与XScroll.js和XScroll2 ...

  9. 30款jQuery常用网页焦点图banner图片切换 下载

    1.jquery 图片滚动特效制作 slide 图片类似窗帘式图片滚动 查看演示 2.jquery幻灯片插件带滚动条的圆形立体图片旋转滚动 查看演示 3.jQuery图片层叠旋转类似洗牌翻转图片幻灯片 ...

随机推荐

  1. linux下epoll如何实现高效处理百万句柄的

    linux下epoll如何实现高效处理百万句柄的 分类: linux 技术分享 2012-01-06 10:29 4447人阅读 评论(5) 收藏 举报 linuxsocketcachestructl ...

  2. jquery中append()、prepend()、after()、before()的区别详解

    append() - 在被选元素的结尾插入内容(内容的结尾,比如说有个a标签,则是在</a>这个标签之前添加东西) prepend() - 在被选元素的开头插入内容(内容的开始,比如说有个 ...

  3. hibernate基础的CRUD的操作

    保存记录 session.save(customer); 根据主键进行查询 Customer customer = (Customer)session.get(Customer.class ,1); ...

  4. Android 自定义title 之Action Bar

    Android 自定义title 之Action Bar 2014-06-29  飞鹰飞龙...  摘自 博客园  阅 10519  转 25 转藏到我的图书馆   微信分享:   Action Ba ...

  5. 宫格布局实例(注意jquery的版本号要统一)2

    <!DOCTYPE html><html><head><meta charset="utf-8" /><style> * ...

  6. nefu1118 最长上升子序列(LIS)

    discription:定义臻.排序数列如下:一个数列删去其中一个数后是从小到大排好序的,称这个数列为臻.排序数列.现在给你一个数列,判断它是否为臻.排序数列. intput:多组输入数据,每组有两行 ...

  7. iOS10 UI教程禁用视图与用户的交互

    iOS10 UI教程禁用视图与用户的交互 在上文中我们提到了使用isHidden属性和alpha属性可以使视图与用户的交互被禁用,除此之外此功能还可以使用UIView的isUserInteractio ...

  8. 关于JSP页面字段属性设为disabled或者readonly所带来的问题总结

    最近需要将页面一些自动求和的字段设为不可操作,当然disabled和readonly都可以实现,但是我的页面需求是来录入数据的,当用disabled时,该字段值是无法被获取并传到后台的,这时如果使用r ...

  9. Floyd_Warshall POJ 1847 Tram

    题目传送门 题意:这题题目难懂.问题是A到B最少要转换几次城市.告诉每个城市相连的关系图,默认与第一个之间相连,就是不用转换,其余都要转换. 分析:把第一个城市权值设为0, 其余设为0.然后Floyd ...

  10. web工程spring+ibatis单元测试

    web工程spring+ibatis在本地做单元测试,用例如下: package wanghongye; import org.junit.Before; import org.junit.Test; ...