查看大图功能代码jquery版


Posted in Javascript onNovember 05, 2013
/*查看大图*/ 
var screenheight = $(window).height(); 
var screenwidth = $(window).width(); 
var loadCSS = function(){ 
var screenwidth = $(window).width(); 
var screenheight = $(window).height(); 
$("div.lookBigPicture").css({"left":screenwidth*0.2,"top":screenheight*0.15+$(document).scrollTop(), 
"width":screenwidth*0.6,"height":screenheight*0.7}); 
$("img.bigImg").css({"max-width":(screenwidth*0.6 - 30),"max-height":screenheight*0.7-40}); 
$("img.bigImg").load(function(){ 
$("img.bigImg").css("top",(screenheight*0.7 - 30 - $("img.bigImg").height())*0.5 + 30); 
}); 
$("img.bigImg").css("top",(screenheight*0.7 - 30 - $("img.bigImg").height())*0.5 + 30); 
$.log("$(document).height():"+$(document).height()); 
}; 
$("a#bigPic").click(function(){ 
$.log("screenheight:"+screenheight+"screenwidth:"+screenwidth); 
str = $("img[img-size]").attr("src"); 
$("body").append("<div class='grey'></div>");//灰色底层 
$("body").append("<div class='lookBigPicture'><span class='protoPic'><a z-index='20001' target='_blank' href='"+str+"'>查看原图</a></span><a href='javascript:;' class='bigpicclose' title='关闭'>×</a><img class='bigImg' src='"+str+"'/></div>"); 
$("div.grey").css( "height",$(document).height()); 
loadCSS(); 
$("body").css({overflow:"hidden"}); //禁用滚动条 
}); 
$("body").delegate("div.grey,a.bigpicclose","click",function(){ 
$("body").css({overflow:"visible"}); //恢复滚动条 
$("div.lookBigPicture").remove(); 
$("div.grey").remove(); 
}); 
//当浏览器窗口大小改变时 
$(window).resize(function () { 
loadCSS(); 
});

/***遮罩层****/ 
.grey { 
background: #000; 
display: block; 
z-index: 1000; 
width: 100%; 
position: absolute; 
filter: alpha(opacity : 50); 
opacity: 0.5; 
top: 0; 
left: 0; 
top: 0; 
} .lookBigPicture { 
border: #000 solid 1px; 
position: absolute; 
z-index: 2000; 
text-align: center; 
background: black; 
} 
.bigImg { 
margin-left: auto; 
margin-right: auto; 
position: relative; 
} 
.bigpicclose { 
position: absolute; 
width: 36px; 
height: 36px; 
font-size: 0; 
z-index: 20001; 
top: -18px; 
right: -18px; 
background: 
url("http://img.t.sinajs.cn/t5/style/images/layer/multipic_ico.png?id=20131018174500") 
0 0 no-repeat; 
} 
.lookbigicn { 
display: inline-block; 
width: 12px; 
height: 12px; 
background: 
url("http://img.t.sinajs.cn/t5/style/images/common/icon.png?id=1383027536816") 
-175px -25px no-repeat; 
vertical-align: -2px; 
margin-left: 20px; 
} 
.W_ico12 { 
display: inline-block; 
width: 12px; 
height: 12px; 
background: 
url("http://img.t.sinajs.cn/t5/style/images/common/icon.png?id=1383027536816") 
-175px 0px no-repeat; 
vertical-align: -2px; 
} 
.protoPic { 
position: absolute; 
display: inline-block; 
height: 30px; 
top: 10px; 
right: 50px; 
overflow: hidden; 
cursor: pointer; 
color: #F8F8F8; 
text-shadow: 0 1px 0 rgba(0, 0, 0, .5); 
}

<p pic-choice style="display: none;"> 
<em class="W_ico12"></em><a href="javascript:;" id="hidePic">收起</a> 
<em class="lookbigicn"></em><a href="javascript:;" id="bigPic">查看大图</a> 
</p>
Javascript 相关文章推荐
javascript下过滤数组重复值的代码
Sep 10 Javascript
ASP.NET jQuery 实例8 (动态添加内容到DropDownList)
Feb 03 Javascript
js屏蔽鼠标键盘(右键/Ctrl+N/Shift+F10/F11/F5刷新/退格键)
Jan 24 Javascript
jQuery 1.9使用$.support替代$.browser的使用方法
May 27 Javascript
JavaScript中的Truthy和Falsy介绍
Jan 01 Javascript
jQuery.position()方法获取不到值的安全替换方法
Mar 13 Javascript
js实现文字无缝向上滚动
Feb 16 Javascript
jQuery+ajax实现修改密码验证功能实例详解
Jul 06 jQuery
angular 表单验证器验证的同时限制输入的实现
Apr 11 Javascript
原生JS实现动态添加新元素、删除元素方法
May 05 Javascript
详解微信小程序图片地扯转base64解决方案
Aug 18 Javascript
vue中npm包全局安装和局部安装过程
Sep 03 Javascript
使用jquery自定义鼠标样式满足个性需求
Nov 05 #Javascript
iframe子页面获取父页面元素的方法
Nov 05 #Javascript
jquery统计复选框选中示例
Nov 05 #Javascript
jquery实现滑动图片自己测试的例子
Nov 05 #Javascript
用js实现in_array的方法
Nov 05 #Javascript
jquery遍历数组与筛选数组的方法
Nov 05 #Javascript
javascript alert乱码的解决方法
Nov 05 #Javascript
You might like
详细介绍PHP应用提速面面观
2006/10/09 PHP
php根据年月获取季度的方法
2014/03/31 PHP
php的XML文件解释类应用实例
2014/09/22 PHP
php中二分法查找算法实例分析
2016/09/22 PHP
如何在PHP环境中使用ProtoBuf数据格式
2020/06/19 PHP
jQuery学习笔记[1] jQuery中的DOM操作
2010/12/03 Javascript
json属性名为什么要双引号(个人猜测)
2014/07/31 Javascript
学习JavaScript设计模式之代理模式
2016/01/12 Javascript
jquery ajax局部加载方法详解(实现代码)
2016/05/12 Javascript
Node.js返回JSONP详解
2016/05/18 Javascript
jQuery progressbar通过Ajax请求实现后台进度实时功能
2016/10/11 Javascript
JS实现仿PS的调色板效果完整实例
2016/12/21 Javascript
详解jquery validate实现表单验证 (正则表达式)
2017/01/18 Javascript
jQuery插件FusionCharts实现的MSBar2D图效果示例【附demo源码】
2017/03/24 jQuery
jQuery简单实现对数组去重及排序操作实例
2017/10/31 jQuery
vue router 跳转后回到顶部的实例
2018/08/31 Javascript
jQuery访问json文件中数据的方法示例
2019/01/28 jQuery
Python中__new__与__init__方法的区别详解
2015/05/04 Python
PyCharm安装第三方库如Requests的图文教程
2018/05/18 Python
Tensorflow使用支持向量机拟合线性回归
2018/09/07 Python
解决os.path.isdir() 判断文件夹却返回false的问题
2019/11/29 Python
Python 模拟动态产生字母验证码图片功能
2019/12/24 Python
Python中使用Selenium环境安装的方法步骤
2021/02/22 Python
使用canvas对多图片拼合并导出图片的方法
2018/08/28 HTML / CSS
Paradigit比利时电脑卖场:购买笔记本、电脑、平板和外围设备
2016/11/28 全球购物
美国女孩服装购物网站:Justice
2017/03/04 全球购物
一份比较全的PHP面试题
2016/07/29 面试题
工商治理实习生的自我评价分享
2014/02/20 职场文书
后勤服务中心总经理工作职责
2014/03/03 职场文书
岗位廉政承诺书
2014/03/27 职场文书
实习公司领导推荐函
2014/05/21 职场文书
小学生安全责任书
2014/07/25 职场文书
领导干部作风建设工作总结
2014/10/23 职场文书
建党伟业观后感
2015/06/01 职场文书
教师节获奖感言
2015/07/31 职场文书
Python爬虫入门案例之回车桌面壁纸网美女图片采集
2021/10/16 Python