欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

jquery實(shí)現(xiàn)彈出層完美居中效果

 更新時(shí)間:2014年03月03日 09:24:57   作者:  
本篇文章主要是對jquery彈出層居中效果的簡單實(shí)例進(jìn)行了介紹,需要的朋友可以過來參考下,希望對大家有所幫助

jquery實(shí)現(xiàn)彈出層完美居中效果

復(fù)制代碼 代碼如下:

showDiv($("#pop"));
function showDiv(obj){
 $(obj).show();
 center(obj);
 $(window).scroll(function(){
  center(obj);
 });
 $(window).resize(function(){
  center(obj);
 });
}

function center(obj){
 var windowWidth = document.documentElement.clientWidth;  
 var windowHeight = document.documentElement.clientHeight;  
 var popupHeight = $(obj).height();  
 var popupWidth = $(obj).width();   
 $(obj).css({  
  "position": "absolute",  
  "top": (windowHeight-popupHeight)/2+$(document).scrollTop(),  
  "left": (windowWidth-popupWidth)/2  
 }); 
}

相關(guān)文章

最新評論