手机
当前位置:查字典教程网 >编程开发 >Javascript教程 >查看大图功能代码jquery版
查看大图功能代码jquery版
摘要:复制代码代码如下:/*查看大图*/varscreenheight=$(window).height();varscreenwidth=$(w...

复制代码 代码如下:

/*查看大图*/

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></div>");//灰色底层

$("body").append("<div><span><a z-index='20001' target='_blank' href='"+str+"'>查看原图</a></span><a href='javascript:;' title='关闭'>×</a><img 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>

<em></em><a href="javascript:;" id="hidePic">收起</a>

<em></em><a href="javascript:;" id="bigPic">查看大图</a>

</p>

【查看大图功能代码jquery版】相关文章:

将HTML自动转为JS代码

加入收藏夹代码(兼容 gecko)

JavaScript中指定函数名称的相关方法

10条建议帮助你创建更好的jQuery插件

7个有用的jQuery代码片段分享

JavaScript实现斗地主游戏的思路

剖析Node.js异步编程中的回调与代码设计模式

强制设为首页代码

简单的防盗链功能代码(iframe)

将HTML自动转为JS代码

精品推荐
分类导航