查看大圖功能代碼jquery版
更新時(shí)間:2013年11月05日 17:37:48 作者:
查看大圖的效果想必大家在瀏覽網(wǎng)頁時(shí)都有看過吧,其實(shí)實(shí)現(xiàn)起來很簡單的,下面有個(gè)不錯(cuò)的示例,喜歡的朋友可以參考下
復(fù)制代碼 代碼如下:
/*查看大圖*/
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='關(guān)閉'>×</a><img class='bigImg' src='"+str+"'/></div>");
$("div.grey").css( "height",$(document).height());
loadCSS();
$("body").css({overflow:"hidden"}); //禁用滾動(dòng)條
});
$("body").delegate("div.grey,a.bigpicclose","click",function(){
$("body").css({overflow:"visible"}); //恢復(fù)滾動(dòng)條
$("div.lookBigPicture").remove();
$("div.grey").remove();
});
//當(dāng)瀏覽器窗口大小改變時(shí)
$(window).resize(function () {
loadCSS();
});
復(fù)制代碼 代碼如下:
/***遮罩層****/
.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);
}
復(fù)制代碼 代碼如下:
<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>
您可能感興趣的文章:
- jQuery實(shí)現(xiàn)點(diǎn)擊查看大圖并以彈框的形式居中
- 基于jQuery實(shí)現(xiàn)表格的查看修改刪除
- jQuery實(shí)現(xiàn)簡單的圖片查看器
- jquery實(shí)現(xiàn)移動(dòng)端點(diǎn)擊圖片查看大圖特效
- jquery實(shí)現(xiàn)點(diǎn)擊查看更多內(nèi)容控制段落文字展開折疊效果
- jquery實(shí)現(xiàn)鼠標(biāo)滑過小圖查看大圖的方法
- jQuery遍歷頁面所有CheckBox查看是否被選中的方法
- JQuery中form驗(yàn)證出錯(cuò)信息的查看方法
- jQuery根據(jù)緯度經(jīng)度查看地圖處理程序
- jQuery輸入城市查看地圖使用介紹
- 查看源碼的工具 學(xué)習(xí)jQuery源碼不錯(cuò)的工具
- 基于jQuery實(shí)現(xiàn)的查看全文功能【實(shí)用】
相關(guān)文章
jQuery使用JSONP實(shí)現(xiàn)跨域獲取數(shù)據(jù)的三種方法詳解
這篇文章主要介紹了jQuery使用JSONP實(shí)現(xiàn)跨域獲取數(shù)據(jù)的三種方法,結(jié)合實(shí)例形式對(duì)比分析了jsonp跨域獲取數(shù)據(jù)的3種常用操作技巧,需要的朋友可以參考下2017-05-05js判斷復(fù)選框是否選中的方法示例【基于jQuery】
這篇文章主要介紹了js判斷復(fù)選框是否選中的方法,結(jié)合實(shí)例形式分析了基于jQuery實(shí)現(xiàn)的復(fù)選框選中判斷相關(guān)操作技巧,需要的朋友可以參考下2019-10-10jQuery 打造動(dòng)態(tài)漸變按鈕 詳細(xì)圖文教程
這是寫給web設(shè)計(jì)者和前端開發(fā)者的教程,我們將演示如何使用Photoshop創(chuàng)建按鈕的sprite圖,然后是如何使用jQurey打造動(dòng)態(tài)漸變效果。2010-04-04jQuery滾動(dòng)加載圖片效果的實(shí)現(xiàn)
實(shí)現(xiàn)滾動(dòng)加載的一個(gè)功能函數(shù),需要的朋友可以參考一下2013-03-03jquery轉(zhuǎn)盤抽獎(jiǎng)功能實(shí)現(xiàn)
這篇文章主要介紹了jquery轉(zhuǎn)盤抽獎(jiǎng)功能實(shí)現(xiàn),實(shí)現(xiàn)的效果是九宮格大轉(zhuǎn)盤抽獎(jiǎng),應(yīng)用特別廣泛的轉(zhuǎn)盤抽獎(jiǎng)方式,感興趣的小伙伴們可以參考一下2015-11-11