gpt4 book ai didi

javascript - 如何使元素 float 在 Jquery 对话框之外

转载 作者:行者123 更新时间:2023-11-29 15:50:34 24 4
gpt4 key购买 nike

我想要一个看起来有点像这样的对话框:

Dialog with items floating outside

我认为这种方法行得通,但我想我错了:

JavaScript

//Creates The Dialog
$('.ImageDialogDiv').dialog({
position: [98, 223],
resizable: false,
//modal: true, /* UNCOMMENT AFTER DEBUGGING */
closeOnEscape: false,
class: 'OverwriteDialogOverflow',
title: $('#hiddenDialogElements').html(),
open: function (event, ui) { $(".ui-dialog-titlebar-close").hide(); }
});

CSS

  /*
* Overrides hidden overflow
*/
.OverwriteDialogOverflow
{
overflow: visible;
}

HTML

<div id = "dialogDiv" class = "ImageDialogDiv"></div>

<div id = "hiddenDialogElements">
<button id = "hiddencloseButton">Close</button>
<div id = "hiddenArrowButtons">
<button class = "ArrowButtonDialogLeft" onclick = "ShowNextImage(-1)" ></button>
<button class = "ArrowButtonDialogRight" onclick = "ShowNextImage(1)" ></button>
</div>
</div>

当我尝试将箭头或关闭按钮移出对话框时,它们被切断并且不可见。我认为添加 .OverwriteDialogOverflow 会解决这个问题。

建议?

最佳答案

如果/当您更新帖子时,我会更详细地编辑它,但我要做的是将对话框和按钮放在具有相对定位的容器 div 中,并使用绝对定位来放置按钮。像下面这样的东西......

HTML:

    <div id = "hiddenDialogElements">
<button id = "hiddencloseButton">Close</button>
<div id = "hiddenArrowButtons">
<button class = "ArrowButtonDialogLeft" onclick = "ShowNextImage(-1)" ></button>
<button class = "ArrowButtonDialogRight" onclick = "ShowNextImage(1)" ></button>
</div>
</div>
</div>

CSS:

.OverwriteDialogOverflow { overflow: visible; }

#dialogContainer { position: relative; }

#hiddencloseButton {
position: absolute;
top: -15px;
right: -15px;
}

#hiddenArrowButtons {
position: absolute;
bottom: -30px;
}

.ui-dialog { overflow: visible; }

编辑:根据评论添加了 .ui-dialog CSS

关于javascript - 如何使元素 float 在 Jquery 对话框之外,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6115947/

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