jQuery UI 对话框未定位在中央屏幕 [英] jQuery UI dialog box not positioned center screen

查看:23
本文介绍了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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆