jQuery UI 对话框未定位在屏幕中心 [英] jQuery UI dialog box not positioned center screen
本文介绍了jQuery UI 对话框未定位在屏幕中心的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个 jQuery 对话框,用于放置在屏幕中间.然而,它似乎在垂直方向上稍微偏离了中心.
I have a jQuery dialog box that is meant to position in the middle of the screen. However, it seems slightly off-center vertically.
代码如下:
$('#add_box').dialog({
autoOpen: true,
width: 300,
modal: true,
resizable: false,
bgiframe:true
});
知道为什么这不会居中吗?
Any ideas why this won't center?
推荐答案
如果您的视口在对话框显示后滚动,它将不再居中.通过从页面添加/删除内容,可能会无意中导致视口滚动.您可以在滚动/调整大小事件期间通过调用使对话框窗口重新居中:
If your viewport gets scrolled after the dialog displays, it will no longer be centered. It's possible to unintentionally cause the viewport to scroll by adding/removing content from the page. You can recenter the dialog window during scroll/resize events by calling:
$('my-selector').dialog('option', 'position', 'center');
这篇关于jQuery UI 对话框未定位在屏幕中心的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文