jQuery图片九宫格样式布局图片切换-20130625

188 篇文章 0 订阅
63 篇文章 0 订阅
1、效果及功能说明
图片九宫格样式布局通过鼠标滑过缩略图进行大小图片切换展示

2、实现原理
通过伪类方法来触发鼠标触及效果触及效果包括,当鼠标移动到小图片上会让背景颜色变亮来告诉用户当前的触及的图片是那张后,当鼠标触及到小图片后触发将触及到的小图片移动到大的div里面并且获得本张图片的路径,做一个放大的效果让图片适应新div的大小的事件后显示出来

3、效果图


[img]http://dl2.iteye.com/upload/attachment/0086/6357/6fb01089-4f69-32c9-930b-e3e5a365ec07.jpg[/img]

4、运行环境

IE6 IE7 IE8及以上 Firefox 和 Google Chrome游览器下都可实现


5、所有图片的压缩包新建一个文件后将包解压放进文件夹图片的压缩包在页面的最下方可以看到并下载下载后无需修改文件夹名因为本身就已经写好了和html5内的路径相吻合

6、将创建html文件保存的时候将编码类型换成(UTF-8有签名)这样可以让部分中文正常的显示出来,将保存类型(T)换成(所有文件(*.*)),将html5和解压后的图片文件夹放在同一个文件夹内效果

7、代码[html5]


[html5]

<!DOCTYPE html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</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 ,"新宋体";}
/* image_show */
.image_show{width:948px;padding:3px 0 0 3px;border:1px solid #d9d9d9;margin:30px auto}
.image_show .img{padding:0 3px 3px 0;position:relative;}
.image_show .img, .image_show .img img{float:left;}
.col_left{width:191px;float:left;overflow:hidden;}
.col_right{float:left;width:450px;overflow:hidden;}
#bigImg{position:relative;width:304px;height:382px;}
#bigImg .img_mask{position:absolute;left:0;top:340px;width:304px;height:42px;background:#000;opacity:0.6;filter:alpha(opacity=60);}
#bigImg p{position:absolute;left:0;top:340px;width:304px;height:42px;line-height:42px;font-size:16px;text-align:center;color:#fff;}
#bigImg p a, #bigImg p a:visited{color:#fff;}
.mask{position:absolute;left:0;top:0;background:#000;opacity:0.4;filter:alpha(opacity=40);}
.clear{height:0;clear:both;line-height:0;font-size:0;overflow:hidden;}
</style>

<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script type="text/javascript">
$(function(){

$('#smallImg img').mouseover(function(){
/*修改smallImg的ID里面的所有img 背景颜色*/
$('#bigImg img').attr('src',$(this).attr('rel'));
/*将出表触碰到的小图片放进大的div里面去通过获得小图片的路径来让大div显示出来*/
$('#bigImg p > a').text($(this).attr('alt'));
/*将小图片的链接一同放到大的div里面去*/
$('#bigImg a').attr('href',$(this).parent().attr('href'));
/*然后在将链接的路径一同放进去*/
});

$('#smallImg .img').hover(function(){
/*同意设定一个伪类在触发鼠标触碰图片的后触发的效果*/
$('.mask').fadeIn();
/*.mask使用淡入效果*/
$(this).children('.mask').hide();
/*弹出以后在通过遍历来使得所有的.mask获得隐藏效果*/
},function(){
$('.mask').fadeIn();
/*接着上面的让鼠标一定到新的图片上让新的图片使用淡入效果*/
});

});
</script>

<div class="image_show">

<div class="img" id="bigImg">
<a href="http://www.17sucai.com"><img height="382" width="304" alt="量变到质变:寻找你的健康Style" src="images/photo/tk3.jpg"></a>
<div class="img_mask"></div>
<p><a href="http://www.17sucai.com">量变到质变:寻找你的健康Style</a></p>
</div>

<div id="smallImg">
<div class="col_left">
<div class="img">
<a href="http://www.17sucai.com"><img height="125" width="189" alt="Steinway and Sons Piano Bag 把钢琴背走 " src="images/tk1-1.jpg" rel="images/photo/tk1.jpg"></a>
<div class="mask" style="width:189px;height:125px;display:block;"></div>
</div>
<div class="img">
<a href="http://www.17sucai.com"><img height="125" width="189" alt="插花老师教你 DIY婚礼花带" src="images/tk2-2.jpg" rel="images/photo/tk2.jpg"></a>
<div class="mask" style="width:189px;height:125px;display:block;"></div>
</div>
<div class="img">
<a href="http://www.17sucai.com"><img height="125" width="189" alt="量变到质变:寻找你的健康Style" src="images/tk3-3.jpg" rel="images/photo/tk3.jpg"></a>
<div class="mask" style="width:189px;height:125px;display:none;"></div>
</div>
</div>

<div class="col_right">
<div class="r_top">
<div class="img">
<a href="http://www.17sucai.com"><img height="172" width="274" alt="圣诞派对 “鞋”能HOLD住" src="images/tk4-4.jpg" rel="images/photo/tk4.jpg"></a>
<div class="mask" style="width:274px;height:172px;display:block;"></div>
</div>
<div class="img">
<a href="http://www.17sucai.com"><img height="171" width="169" alt="北海道的风土滋味:北京日料" src="images/tk5-5.jpg" rel="images/photo/tk5.jpg"></a>
<div class="mask" style="width:169px;height:171px;display:block;"></div>
</div>
</div>

<div class="clear"></div>

<div class="r_bottom">
<div class="img">
<a href="http://www.17sucai.com"><img height="208" width="147" alt="汪星人来袭 你准备了吗" src="images/tk6-6.jpg" rel="images/photo/tk6.jpg"></a>
<div class="mask" style="width:147px;height:208px;display:blcok;"></div>
</div>
<div class="img">
<a href="http://www.17sucai.com"><img height="208" width="147" alt="穿针器:懒人刺绣有保证" src="images/tk7-7.jpg" rel="images/photo/tk7.jpg"></a>
<div class="mask" style="width:147px;height:208px;display:block;"></div>
</div>
<div class="img">
<a href="http://www.17sucai.com"><img height="208" width="147" alt="可爱的圣诞铃铛教你折一个" src="images/tk8-8.jpg" rel="images/photo/tk8.jpg"></a>
<div class="mask" style="width:147px;height:208px;display:block;"></div>
</div>
</div>
</div>

</div>

<div class="clear"></div>

</div>

</body>
</html>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值