以下是 脸谱换换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 rel="stylesheet" href="css/index.css"/>
<link rel="stylesheet" href="css/main.css"/>
<SCRIPT type=text/javascript src="js/jquery-1.4.2.min.js"></SCRIPT>
<script type=text/javascript src="js/jquery.tools.min.js"></script>
<script type="text/javascript" src="js/jquery.easing.1.3.js"></script>
<script type="text/javascript" src="js/slide.js"></script>
</head>
<body>
<div class="banner">
<DIV id=home-slide class=slide-show>
<div id="triggers">
</div>
<div class="focus-box">
<div class="mobile-box">
<ul class="mobile-img-list">
<li><img src="images/1.png" alt="" /></li>
<li><img src="images/2.png" alt="" /></li>
<li><img src="images/3.png" alt="" /></li>
<li><img src="images/4.png" alt="" /></li>
</ul>
</div>
<div class="info-box">
<ul class="info-img-list">
<li><img src="images/1_1.png" alt="" /></li>
<li><img src="images/2_2.png" alt="" /></li>
<li><img src="images/3_3.png" alt="" /></li>
<li><img src="images/4_4.png" alt="" /></li>
</ul>
</div>
<ul class="controls">
<li class="current"></li>
<li></li>
<li></li>
<li></li>
</ul>
</div>
</div>
</DIV>
<script type=text/javascript>
$(document).ready(function(){
if($(".weibo-list > li").size() >= 3)
{
$(".weibo-list").scroll();
}
$("#nav_index").addClass("current");
});
$(function(){
$('.focus-box').slide({
loop: '.mobile-img-list,.info-img-list',
loopBox: 'parent',
conClass: 'current',
speed: 500,
gap: 5000,
next: '.focus-img-next-btn',
prev: '.focus-img-prev-btn',
control: '.controls'
});
});
</script>
</body>
</html>
JS代码(slide.js):
(function($){
$.fn.extend({
slide:function(options){
var o ={
loop:'',conClass:'',speed:500,gap:5000,next:'',prev:'',control:''}
;
$.extend(o,options);
var loop = $(o.loop),control = $(o.control),maxLen = control.children().length - 1,timer = null,conClass = o.conClass,isLoop = true,loopsSize = [],tSize = [],cell = [],currentPage = 0,star = function(){
clearTimeout(timer);
timer = setTimeout(autoPlay,o.gap);
}
,autoPlay = function(){
setCell();
move();
}
,move = function(){
$('.' + conClass,control).removeClass(conClass);
control.children().eq(currentPage).addClass(conClass);
loop.each(function(i,n){
$(n).animate({
left:'-'+cell[i]+'px'}
,o.speed,'easeOutCirc',function(){
if(isLoop) star();
}
);
}
);
}
,setCell = function(){
if(currentPage < 0){
currentPage = maxLen;
}
else if(currentPage < maxLen){
currentPage += 1;
}
else{
currentPage = 0;
}
$.each(cell,function(i){
cell[i] = currentPage * tSize[i];
}
);
}
,stop = function(){
clearTimeout(timer);
}
,jump = function(idx){
currentPage = idx;
if(idx < 0){
currentPage = maxLen;
}
else if(idx > maxLen){
currentPage = 0;
}
$.each(cell,function(i){
cell[i] = currentPage * tSize[i];
}
);
move();
}
;
loop.each(function(i,n){
var tt = $(this);
tSize[i] = tt.parent().width();
loopsSize[i] = tSize[i] * (maxLen + 1);
cell[i] = 0;
tt.width(loopsSize[i]);
}
);
star();
this.hover(stop,star);
control.delegate('li','mouseenter',function(){
clearTimeout(timer);
var that = $(this);
if(that.is('.' + conClass)) return;
var index = that.index();
loop.stop();
isLoop = false;
jump(index);
}
) .delegate('li','mouseleave',function(){
isLoop = true;
star();
}
);
if(o.prev){
$(o.prev).live('click',function(){
clearTimeout(timer);
var idx = control.children('.'+conClass).index();
loop.stop();
jump(idx - 1);
return false;
}
);
}
if(o.next){
$(o.next).live('click',function(){
clearTimeout(timer);
var idx = control.children('.'+conClass).index();
loop.stop();
jump(idx + 1);
return false;
}
);
}
}
}
)}
)(jQuery);
CSS代码(index.css):
/* CSS Document */
body{font-size:12px;margin:0px;}
#top{width:100%;height:45px;background:url(huanhuandhbj.png) left repeat-x;}
#top .alliconshow{width:100%;height:45px;margin:0 auto;background:url(logo2.png) no-repeat 37px top;}
#top .alliconshow .homeicon{width:140px;height:45px;margin:0 auto;}
.banner{width:100%;height:507px;margin:0 auto;background:url(hh_bannerbj.png) repeat-x center center;}
.logo{width:109px;height:45px;position:relative;left:37px;float:left;}
/************************************************************************banner图片切换效果CSS开始**********************************************************************************************/
.slide-show{Z-INDEX:10;POSITION:relative;WIDTH:1003px;height:507px;margin:0 auto;display:block;background:url(bannerbj1.png);}
.slide-show .current-slide{VISIBILITY:visible;}
.slide-image{Z-INDEX:11;POSITION:absolute;VISIBILITY:hidden;margin-top:0px;margin-left:500px;}
/*.slide-show UL{Z-INDEX:20;POSITION:absolute;DISPLAY:block;TOP:460px;LEFT:350px;width:604px;height:26px;background:url(banner_tabbj2.png) no-repeat left;padding-left:15px;}
.slide-show UL LI{LIST-STYLE-TYPE:none;WIDTH:auto;FLOAT:left;HEIGHT:26px;margin-right:10px;margin-left:10px;CURSOR:pointer;line-height:30px;color:#949494;white-space:nowrap;_overflow:hidden;_padding-top:10px;}
.chinaz-zzsc UL background:url(banner_tabbj2.png) no-repeat left;.slide-show UL LI img{margin-left:15px;vertical-align:middle\9;*margin-bottom:3px;display:inline;overflow:hidden;}
.slide-show UL .current{BACKGROUND:url(smalldhbj.jpg) no-repeat center center;color:#FFF;_BACKGROUND:url(smalldhbj.jpg) no-repeat -7px 5px;}
.slide-show UL .hover{BACKGROUND:url(smalldhbj.jpg) no-repeat center center;_BACKGROUND:url(smalldhbj.jpg) no-repeat -7px 5px;}
*/
/************************************************************************banner图片切换效果CSS结束**********************************************************************************************/
CSS代码(main.css):
html,body,div,p,span,a,strong,form,table,th,td,ul,li,ol,dl,dt,dd,h1,h2,h3,h4,h5,h6,fieldset,iframe,object,pre,img,b,i{border:0 none;margin:0;outline:0 none;padding:0;}
ul,ol,li{list-style:none;}
table{border-collapse:collapse;border-spacing:0;}
fieldset,img{border:0 none;}
h1,h2,h3,h4,h5,h6{font-size:100%;}
body,table,input,textarea,button,select{font-family:Tahoma,sans-serif;font-size:12px;}
.clr{clear:both;height:0;font-size:0;}
a{text-decoration:none;color:#2297ea;}
a:hover{text-decoration:underline;}
body{repeat-x;width:100%;}
.index,.down,.down-info{background:url(index-bg.jpg) center top no-repeat;min-height:760px;width:100%;}
.header{width:1120px;margin:auto;height:164px;position:relative;background:url(header-bg.jpg) no-repeat;}
.logo{position:absolute;top:45px;left:55px;width:260px;height:90px;}
.nav{position:absolute;top:76px;left:440px;}
.nav a{float:left;padding:0 16px;height:88px;line-height:48px;margin-right:30px;color:#233d5e;font-family:微软雅黑;font-size:22px;}
.nav a:hover{color:#3399ff;text-decoration:none;}
.nav a.current{background:url(nav-bg.png) right top no-repeat;color:#fff;line-height:88px;}
.nav a.current:hover{color:#fff;}
.content{width:1120px;margin:auto;position:relative;}
.index .content{background:url(index-content-bg.jpg) no-repeat;}
.down .content{background:url(down-content-bg.jpg) no-repeat;min-height:309px;}
.index-focus{height:598px;}
.focus-box{height:450px;width:882px;position:absolute;left:124px;top:35px;}
.mobile-box{position:absolute;left:498px;top:71px;width:194px;height:291px;overflow:hidden;}
.mobile-img-list{height:427px;position:absolute;}
.mobile-img-list li{float:left;width:194px;height:291px;}
.info-box{position:absolute;left:-170px;top:0;width:540px;height:426px;overflow:hidden;}
.info-img-list{height:450px;position:absolute;}
.info-img-list li{float:left;width:540px;height:426px;}
.info-img-list li img{filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod='scale')}
.controls{position:absolute;left:11%;top:435px;height:14px;}
.controls li{position:relative;left:-50%;width:13px;height:14px;background:url(focus-point.png) -13px 0 no-repeat;margin-right:20px;cursor:pointer;overflow:hidden;float:left;}
.controls li.current{background-position:0 0;}
.mobile{position:absolute;left:95px;top:-19px;background:url(mobile.jpg) no-repeat;width:340px;height:560px;}