jquery - 居中 jQuery 模态对话框弹出窗口

标签 jquery css jquery-ui modal-dialog jquery-ui-dialog

我试图在用户访问我的主页时显示模式对话框/弹出窗口。

我可以显示对话框,但它没有出现在屏幕中央。

我正在导入这些文件,以防出现问题:

<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>

<script language="JavaScript" type="text/javascript"> 
$(function () { 
    $("#dialog-modal").dialog({ 
    width: 'auto',
    // position: 'center',
    center: true, 
    modal: true, 
    autoOption: true, 
    resizable: false 
    }); 
}); 
</script>

<div id="dialog-modal" title="Offer" style="text-align:center"><img alt="" src="Pack.jpg"/> </div>

我的 fiddle :http://jsfiddle.net/szEpb/

谢谢

最佳答案

尝试取消注释 //position: 'center',

或者如果它不起作用,请尝试下面的代码。希望这就是你的意思......:)

$('body').dialog('option', 'position', 'center');

如果您需要在特定选择器处居中,请尝试

$('your_selector').dialog('option', 'position', 'center');

关于jquery - 居中 jQuery 模态对话框弹出窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19219538/

相关文章:

javascript - jquery show() 在 IE 7 中移动其他元素

jquery - 用 jQuery 重置点击事件?

css - 将旁边的div向下推到页面时,使div宽度为100%

javascript - 在 li 上添加叠加图像

javascript - 通知 Polymer dom-repeat 对本地 DOM 的更改

javascript - 将响应度添加到图像 slider

javascript - 如何使用jquery选择特定位置的元素

html - 移动版 chrome 顶部栏的颜色

javascript - 如何限制具有 parent 权利和底部值(value)的可拖动 child ?

jquery - 如何根据服务器日期格式设置 jQuery UI datepicker 的 dateFormat?