Posted in Javascript onMarch 03, 2014
jquery实现弹出层完美居中效果
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 }); }
jquery实现弹出层完美居中效果
声明:登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述。
Reply on: @reply_date@
@reply_contents@