jq图片切换特效
首先引入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图片切换特效的更多相关文章
- jQuery旋转木马仿3D效果的图片切换特效代码
		
用jQuery实现的一款仿3D效果的图片切换特效代码,类似旋转木马一样,幻灯图片以三维视觉上下滑动切换,效果很酷炫,兼容IE8.360.FireFox.Chrome.Safari.Opera.傲游.搜 ...
 - Winform下实现图片切换特效的方法
		
本文实例讲述了Winform下实现图片切换特效的方法,是应用程序开发中非常实用的一个功能.分享给大家供大家参考之用.具体方法如下: 本实例源自网络,功能较为齐全.丰富!主要功能代码如下: using ...
 - 基于HTML5 SVG和CSS3炫酷蹦床式图片切换特效
		
今天给大家分享一款效果非常炫酷的HTML5 SVG和CSS3蹦床式图片切换特效插件.该图片切换插件在进行图片切换时,整个屏幕就像一张大蹦床一样,将图片弹射出去,切换到另一张图片,效果非常有创意.效果图 ...
 - 一款基于jquery超炫的图片切换特效
		
今天为给大家介绍一款基于jquery超炫的图片切换特效.由百叶窗飞入显示图片.图片消息的时候也是百叶窗渐行渐远.用于图片展示,效果还是非常好,我们一起看下效果图: 在线预览 源码下载 来看下实现的 ...
 - css3全屏背景图片切换特效
		
效果体验:http://hovertree.com/texiao/css3/10/ 一般做图片切换效果,都会使用JS或者jQuery脚本,今天发现,其实只用CSS也可以实现.试试效果吧. 效果图: 代 ...
 - JS组件系列——图片切换特效:简易抽奖系统
		
前言:前两天在网上找组件,无意中发现了我们儿时游戏机效果的“SlotMachine组件”,浏览一遍下来,勾起了博主小时候满满的回忆.于是下定决定要研究下这么一个东西,不得不再次叹息开源社区的强大,原来 ...
 - ES6实现图片切换特效
		
效果图 demo.html <!DOCTYPE html> <html lang="en"> <head> <meta charset=& ...
 - javascript马赛克遮罩图片切换效果:XMosaic.js(转)
		
新鲜出炉的javascript图片切换特效,实现的是马赛克遮罩切换.在flash里,好实现遮罩动画很简单,不过JS实现起来就有些困难了. XMosaic.js,与XScroll.js和XScroll2 ...
 - 30款jQuery常用网页焦点图banner图片切换 下载
		
1.jquery 图片滚动特效制作 slide 图片类似窗帘式图片滚动 查看演示 2.jquery幻灯片插件带滚动条的圆形立体图片旋转滚动 查看演示 3.jQuery图片层叠旋转类似洗牌翻转图片幻灯片 ...
 
随机推荐
- merge布局
			
当LayoutInflater遇到这个标签时,它会跳过它,并将<merge />内的元素添加到<merge />的父元素里.迷惑了吗?让我们用<merge />来替 ...
 - MySQL中的SQL语言
			
从功能上划分,SQL 语言可以分为DDL,DML和DCL三大类.1. DDL(Data Definition Language)数据定义语言,用于定义和管理 SQL 数据库中的所有对象的语言 :CRE ...
 - Android 通过Java代码生成创建界面。动态生成View,动态设置View属性。addRules详解
			
废话不多说,本文将会层层深入给大家讲解如何动态的生成一个完整的界面. 本文内容: Java代码中动态生成View Java代码中动态设置View的位置,以及其他的属性 LayoutParams详解 一 ...
 - python 文件操作总结
			
Python 文件I/O 本章只讲述所有基本的的I/O函数,更多函数请参考Python标准文档. 打印到屏幕 最简单的输出方法是用print语句,你可以给它传递零个或多个用逗号隔开的表达式.此函数把你 ...
 - ASP.NET 取消和禁用缓存
			
客户端取消: <html> <head> <meta http-equiv="Expires" CONTENT="0"> & ...
 - AngularJS学习之全局API(应用程序编程接口)
			
1.AngularJS全局API用于执行常见任务的Javascript函数集合: **比较对象 **迭代对象 **转换对象 2.全局API函数使用angularJS对象进行访问:以下是通用API函数: ...
 - POJ 3693 后缀数组
			
题目链接:http://poj.org/problem?id=3693 题意:首先定义了一个字符串的重复度.即一个字符串由一个子串重复k次构成.那么最大的k即是该字符串的重复度.现在给定一个长度为n的 ...
 - [自动运维]weblogic自动发布
			
近期一个项目属于测试过渡期,bug修复比较频繁,每次都会伴随着项目的打包.上传.发布,此类重复操作近乎每天都会进行,刚好最近在看python相关资料,决定重新将此前学习的weblogic的wlst相关 ...
 - 利用StringList对象来管理这些动态生成的对象
			
如果程序需要动态创建大量的对象,那么我们可以利用StringList对象来管理这些动态生成的对象.1.创建StringList对象:OBJ := TStringList.Create; 2.保存动态生 ...
 - 转:Delphi 回调函数及例子
			
http://anony3721.blog.163.com/blog/static/5119742010866050589/ { http://anony3721.blog.163.com/blog/ ...