码迷,mamicode.com
首页 > Web开发 > 详细

相册弹窗(基于zepto.js)

时间:2016-06-21 15:18:48      阅读:226      评论:0      收藏:0      [点我收藏+]

标签:

技术分享

 1     //放大图片
 2         $(page).on(‘click‘,‘.popupImage img‘,function () {
 3             var that = $(this);
 4             that.popupImage({
 5                 this:that,
 6                 width:"200px"
 7             })
 8         });
 9 
10   //相册弹窗
11     $.fn.popupImage = function (obj) {
12         var $this = obj.this;
13         var sj_w = $this[0].naturalHeight;
14         var src = $this.attr(‘src‘);
15         var h = $(‘body‘).height();
16         var w = $(‘body‘).width();
17         var padding = 10;
18         var shadeW = w - padding*2;
19         var img = ‘‘,shade = ‘‘;
20         
21         img = ‘<div class="popup-image" style="position:absolute; top:0; left:0; z-index: 999999; padding:10px ‘+padding+‘px; width: ‘+w+‘px; height:‘+h+‘px; line-height: ‘+h+‘px; text-align: center;" >‘ +
22             ‘<img src="‘+src+‘" style="max-width: ‘+shadeW+‘px"/></div>‘;
23         shade = ‘<div class="shade" style="position:absolute; top:0; left:0;  width: ‘+w+‘px; height:‘+h+‘px;background: #000; z-index: 999990; opacity: .8;"></div>‘;
24 
25         $(‘body‘).append(shade);
26         $(‘body‘).append(img);        
27 
28         $(‘.popup-image‘).on(‘click‘,function () {
29             $(‘.popup-image‘).remove();
30             $(‘.shade‘).remove();
31         })
32 
33     };

 

相册弹窗(基于zepto.js)

标签:

原文地址:http://www.cnblogs.com/zhangxusong/p/5603487.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!