Mik*_*ike 6 jquery modalpopups
好的.我正在使用模态框弹出窗口来显示动态表的业务详细信息.这张桌很长.一切都适用于模态框,但如果说它们滚动到页面底部,它总是打开页面顶部的模态框.因此他们必须以这种方式进行大量滚动.
我目前正在使用此代码来集中我的模态框.
function centerPopup(x){
//request data for centering
var windowWidth = document.documentElement.clientWidth;
var windowHeight = document.documentElement.clientHeight;
var popupHeight = $("#popup" + x).height();
var popupWidth = $("#popup" + x).width();
//centering
$("#popup" + x).css({
"position": "absolute",
"top": windowHeight/2-popupHeight/2,
"left": windowWidth/2-popupWidth/4
});
//only need force for IE6
$('#backgroundPopup').css({
"height": windowHeight
});
}
Run Code Online (Sandbox Code Playgroud)
我不知道这段代码中是否有影响它的东西.一个解决方法是必须向下滚动到它们之前的位置,但我找不到关于.position的文档.
Mik*_*ike 12
http://www.west-wind.com/weblog/posts/459873.aspx
这个人建立了一个插件,通过添加.centerInClient来居中页面中的任何元素.非常光滑.节省时间.