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

查看:109
本文介绍了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天全站免登陆