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   
     });  
}

 

转载自:http://www.w3cfuns.com/blog-5396619-5395246.html

相关文章:

  • 2021-09-29
  • 2021-04-20
  • 2022-12-23
  • 2022-12-23
  • 2021-12-29
  • 2021-08-29
  • 2021-07-19
猜你喜欢
  • 2022-12-23
  • 2021-10-01
  • 2021-11-14
  • 2022-12-23
  • 2022-03-05
  • 2022-12-23
  • 2022-03-05
相关资源
相似解决方案