我刚刚下载了 jQuery 1.8.0,也带有自定义的 CSS,并且正在尝试制作一个非常简单的 jQuery 对话框来工作,但是它不会在当前视口中居中,而是在父元素(主体)中并滚动对话框的视口盒子在中间。
我包含了小部件和位置 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 position center screen
jQuery center element to viewport using center plugin
有谁知道如何解决这个问题?这是 jQuery 对话框的标准行为吗?对我来说似乎很奇怪,还是我弄错了?