编程语言
首页 > 编程语言> > javascript – jQuery对话框不以viewport为中心,而是父元素

javascript – jQuery对话框不以viewport为中心,而是父元素

作者:互联网

我刚刚下载了jQuery 1.8.0,也使用了自定义CSS,我试图让一个非常简单的jQuery对话框工作,但是它不会居中在当前视口中而是在父元素(body)中并滚动视口对话框盒子在中心.

我包括小部件和位置js文件,并检查路径是否正确.这就是我所拥有的:

<script src="js/js/jquery-1.8.0.min.js"></script>
<script src="js/js/jquery-ui-1.8.23.custom.min.js"></script>
<script src="js/js/jquery.ui.position.js"></script>
<script src="js/js/jquery.ui.widget.js"></script>

HTML:

<div id="dialog-confirm" title="Empty the recycle bin?">
    <p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span>These items will be permanently deleted and cannot be recovered. Are you sure?</p>
</div>

HTML完全是从jQuery网站复制的.最后称它为:

var dialog_confirm=$( '#dialog-confirm' ).dialog();
dialog_confirm.dialog('open');

这些问题中的所有解决方案都没有为我解决:
Dialog box not positions center screen
jQuery center element to viewport using center plugin

有人知道如何解决这个问题吗?这是jQuery对话框的标准行为吗?对我来说似乎很奇怪,或者我错了?

解决方法:

如果可以,请尝试使用较旧的jquery版本,例如1.7.x ……这可能会解决它.这不是一种常见的行为!

标签:jquery-dialog,javascript,jquery,scroll,viewport
来源: https://codeday.me/bug/20190826/1726616.html