gpt4 book ai didi

javascript - 当前屏幕中间的 JQuery 位置

转载 作者:行者123 更新时间:2023-11-28 05:33:23 26 4
gpt4 key购买 nike

我正在像这样使用 Jquery 对话框:

<body>
<div id="comments_dialog">
Insert a comment
<form>
<input type="text" id="search" name="q">
</form>
</div>
....
</body>



dialog = $( "#comment_dialog" ).dialog({
autoOpen: false,
height: 400,
width: 350,
dialogClass: "flora",
modal: true,
buttons: {
"New Comment": addComment,
Cancel: function() {
dialog.dialog( "close" );
}
},
close: function() {
form[ 0 ].reset();
}
});

我的页面是一个包含大量数据的可滚动页面。

问题是对话框显示在页面中间,我希望它显示在当前屏幕的中间,这样用户就不需要滚动就能看到它。

我该怎么做?

已编辑

基于这里的一些解决方案,我将CSS设置为这样固定:

.flora.ui-front {
z-index: 1000 !important;
position:fixed !important;
}
.flora.ui-dialog {
z-index: 1001 !important;
position:fixed !important;
}

但是,我读到 position fixed 与 zIndex 冲突。在这种情况下,我需要将对话框放在当前屏幕的顶部和中间,我该怎么办?

最佳答案

您可能在您的 css 中使用了 position:absolute;,请尝试将其更改为 position:fixed;

#comment_dialog{
position:fixed;
}

关于javascript - 当前屏幕中间的 JQuery 位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38373560/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com