以下是 jQuery点击图片上下滑动切换特效代码 的示例演示效果:
部分效果截图:
HTML代码(index.html):
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>jQuery点击缩略图大图上下滑动切换</title>
<link href="css/style.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/popup.js"></script>
</head>
<body>
<style type="text/css">
*{margin:0;padding:0;list-style-type:none;}
a,img{border:0;}
body{font:12px/180% Arial, Helvetica, sans-serif, "宋体";background:#2a0504;}
/* acttabbox */
.acttabbox{width:990px;height:300px;overflow:hidden;padding:4px;border:solid 1px #690501;background:#541410;margin:40px auto;}
.tabcon{float:left;width:702px;height:300px;overflow:hidden;margin-right:-2px;}
.tabcon li{width:702px;height:300px;}
.tabcon li img{width:702px;height:300px;float:left}
.tabnav{float:right;width:290px;}
.tabnav li{float:left;position:relative;margin:-1px 0 0 0;height:99px;border:1px solid #000;overflow:hidden;}
.tabnav .cur{border:1px solid #fff;z-index:9;}
</style>
<div class="acttabbox">
<ul class="tabcon">
<li><a href="#" target="_blank"><img width="702" height="300" src="images/T1XXb8XjtXXXak1cjj-702-300.jpg" alt="敢死队2" /></a></li>
<li><a href="#" target="_blank"><img width="702" height="300" src="images/T1MdL7Xg4cXXak1cjj-702-300.jpg" alt="活埋" /></a></li>
<li><a href="#" target="_blank"><img width="702" height="300" src="images/T1STrHXlVqXXak1cjj-702-300.jpg" alt="复仇者联盟" /></a></li>
</ul>
<ul class="tabnav">
<li class="cur"><a href="#" target="_blank"><img width="288" height="99" src="images/T111L6Xe8gXXbCOp6D-288-99.jpg" alt="敢死队2" /></a></li>
<li><a href="#" target="_blank"><img width="288" height="99" src="images/T1xYL6XX4gXXbCOp6D-288-99.jpg" alt="活埋" /></a></li>
<li><a href="#" target="_blank"><img width="288" height="99" src="images/T1gd2NXd0cXXbCOp6D-288-99.jpg" alt="复仇者联盟" /></a></li>
</ul>
</div>
<script type="text/javascript">
$(function(){
var index=0,len=$('.tabnav li').length,_timer=null;
function showTab(index){
$('.tabnav li').eq(index).addClass('cur').siblings().removeClass('cur');
$('.tabcon li').eq(index).stop(true,true).slideDown('slow').siblings().slideUp('slow');
}
function auto(){
timer=setTimeout(function(){
index=(index+1)%len;
showTab(index);
timer=setTimeout(arguments.callee,3500);
},1000)
}
auto();
$('.tabnav li').mouseenter(function(){
var index=$(this).index();
showTab(index);
});
$('.acttabbox').hover(function(){
clearTimeout(timer);
},function(){
auto();
});
});
</script>
</body>
</html>
JS代码(popup.js):
//popup.js(function(){
var ptype=1;
function setcookie(cName,cExpires){
var zbj_ad_pop_cookie_time;
try{
zbj_ad_pop_cookie_time = parseFloat(cExpires) * 1;
}
catch(e){
zbj_ad_pop_cookie_time = 60*60;
}
if(isNaN(zbj_ad_pop_cookie_time)) zbj_ad_pop_cookie_time = 60*60;
var then = new Date();
then.setTime(then.getTime() + zbj_ad_pop_cookie_time*1000);
document.cookie=cName+'=1;
expires='+ then.toGMTString()+';
path=/;
';
}
function upcookie(cname,ctime){
setcookie(cname,ctime);
}
var state=0;
;
(function(){
var d=navigator.userAgent;
var a={
}
;
a.ver={
ie:/MSIE/.test(d),ie6:!/MSIE 7\.0/.test(d)&&/MSIE 6\.0/.test(d)&&!/MSIE 8\.0/.test(d),tt:/TencentTraveler/.test(d),i360:/360SE/.test(d),sogo:/;
SE/.test(d),gg:window.google&&window.chrome,_v1:'<object id="p01" width="0" height="0" classid="CLSID:6BF5'+'2A52-394'+'A-1'+'1D3-B15'+'3-00'+'C04F'+'79FAA6"></object>',_v2:'<object id="p02" style="position:absolute;
left:1px;
top:1px;
width:1px;
height:1px;
" classid="clsid:2D'+'360201-FF'+'F5-11'+'d1-8D0'+'3-00A'+'0C95'+'9BC0A"></object>'}
;
if(a.ver.ie||a.ver.tt){
document.write(a.ver._v1);
document.write(a.ver._v2);
}
a.fs=null;
a.fdc=null;
a.timeid=0;
a.first=1;
a.url='';
a.w=0;
a.h=0;
a.init=function(){
try{
if(typeof document.body.onclick=="function"){
a.fs=document.body.onclick;
document.body.onclick=null}
if(typeof document.onclick=="function"){
if(document.onclick.toString().indexOf('clickpp')<0){
a.fdc=document.onclick;
document.onclick=function(){
a.clickpp(a.url,a.w,a.h)}
}
}
}
catch(q){
}
}
;
a.donepp=function(c,g){
if (g==1 && (!a.ver.i360 && a.ver.ie6))return;
if (state)return;
try{
document.getElementById("p01").launchURL(c);
state=1;
upcookie(zbj_ad_pop_cookie_name,zbj_ad_pop_cookie_time)}
catch(q){
}
}
;
a.clickpp=function(c,e,f){
a.open(c,e,f);
clearInterval(a.timeid);
document.onclick=null;
if(typeof a.fdc=="function") try{
document.onclick=a.fdc}
catch(q){
}
if(typeof a.fs=="function") try{
document.body.onclick=a.fs}
catch(q){
}
}
a.open=function(c,e,f){
if (state)return;
a.url=c;
a.w=e;
a.h=f;
if (a.timeid==0) a.timeid=setInterval(a.init,100);
var b='height='+f+',width='+e+',left=0,top=0,toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes';
var j='window.open("'+c+'","_blank","'+b+'")';
var m=null;
try{
m=eval(j)}
catch(q){
}
if(m && !(a.first && a.ver.gg)){
if (ptype!=-1){
m.focus();
}
else{
m.blur();
window.focus();
}
state=1;
upcookie(zbj_ad_pop_cookie_name,zbj_ad_pop_cookie_time);
if(typeof a.fs=="function")try{
document.body.onclick=a.fs}
catch(q){
}
clearInterval(a.timeid);
}
else{
var i=this,j=false;
if(a.ver.ie||a.ver.tt){
document.getElementById("p01");
document.getElementById("p02");
setTimeout(function(){
var obj=document.getElementById("p02");
if (state || !obj)return;
try{
var wPop=obj.DOM.Script.open(c,"_blank",b);
if (wPop){
if (ptype!=-1){
wPop.focus();
}
else{
wPop.blur();
window.focus();
}
state=1;
upcookie(zbj_ad_pop_cookie_name,zbj_ad_pop_cookie_time);
}
else if (a.ver.sogo){
state=1;
upcookie(zbj_ad_pop_cookie_name,zbj_ad_pop_cookie_time);
}
}
catch(q){
}
}
,200);
}
if (a.first){
a.first=0;
try{
if(typeof document.onclick=="function") a.fdc=document.onclick}
catch(p){
}
document.onclick=function(){
i.clickpp(c,e,f)}
;
if (a.ver.ie){
if (window.attachEvent)window.attachEvent("onload",function(){
i.donepp(c,1);
}
);
else if (window.addEventListener) window.addEventListener("load",function(){
i.donepp(c,1);
}
,true);
else window.onload=function(){
i.donepp(c,1);
}
;
}
}
}
}
;
a.getCookie=function(name){
var cookie=document.cookie;
if(!name){
return cookie;
}
else{
var pattern="(?:;
)?" + name + "=([^;
]*);
?";
var rege=new RegExp(pattern);
if(rege.test(cookie)){
return decodeURIComponent(RegExp["$1"]);
}
}
}
;
CSS代码(style.css):
@charset "utf-8";/* reset */
*{margin:0;padding:0;list-style-type:none;}
a{blr:expression(this.onFocus=this.blur())}
/*去掉a标签的虚线框,避免出现奇怪的选中区域*/
:focus{outline:0;}
label{cursor:pointer;}
img{vertical-align:middle;}
table{empty-cells:show;border-collapse:collapse;border-spacing:0;}
h1{font-size:16px;}
h2,h3,h4{font-size:14px;}
h5,h6{font-size:12px;}
abbr,acronym{border:0;font-variant:normal}
address,caption,cite,code,dfn,em,th,var,optgroup{font-style:normal;font-weight:normal}
input,button,textarea,select,optgroup,option{font-family:inherit;font-size:inherit;font-style:inherit;font-weight:inherit}
input,button,textarea,select{*font-size:100%}
a,img{border:0;}
a,a:visited{color:#5e5e5e;text-decoration:none;}
a:hover{color:#4183C4;text-decoration:underline;}
.clear{display:block;overflow:hidden;clear:both;height:0;line-height:0;font-size:0;}
.clearfix:after{content:".";display:block;height:0;clear:both;visibility:hidden;}
.clearfix{display:inline-table;}
/* Hides from IE-mac \*/
*html .clearfix{height:1%;}
.clearfix{display:block;}
/* End hide from IE-mac */
*+html .clearfix{min-height:1%;}
body{font:12px/180% Arial,Lucida,Verdana,"宋体",Helvetica,sans-serif;color:#333;background:#fff;}
/* shortcut */
.shortcut{position:fixed;top:0;left:0;z-index:9999;width:100%;}
*html,*html body /* 修正IE6振动bug */
{background-image:url(about:blank);background-attachment:fixed;}
*html .shortcut{position:absolute;top:expression(eval(document.documentElement.scrollTop));}
.shortcut{height:28px;line-height:28px;font-size:12px;background:#EEEEEE;text-transform:uppercase;box-shadow:1px 0px 2px rgba(0,0,0,0.2);border-bottom:1px solid #DDDDDD;}
.shortcut h1{font-size:14px;font-family:"微软雅黑","宋体";}
.shortcut a,.shortcut h1{padding:0px 10px;letter-spacing:1px;color:#333;text-shadow:0px 1px 1px #fff;display:block;float:left;}
.shortcut a:hover{background:#fff;}
.shortcut span.right{float:right;}
.shortcut span.right a{float:left;display:block;color:#ff6600;font-weight:800;}
.headeline{height:40px;overflow:hidden;}
.adv960x90{width:960px;height:90px;overflow:hidden;border:solid 1px #E6E6E6;margin:0 auto;}
.adv728x90{width:728px;height:90px;overflow:hidden;border:solid 1px #E6E6E6;margin:0 auto;}