【发布时间】:2019-10-31 13:45:53
【问题描述】:
制作一个带有选项的对话框,但当按钮中的文本太长时,它们会相互堆叠。我需要它彼此相邻(并且可能超出对话框的宽度)。尝试了不同的显示器和浮动,但无法改变任何东西......
我希望它看起来像这样(我在这篇文章中省略了 CSS,所以不要注意它):
image of how I want it to look
另外:在学校项目中必须使用 jQuery...
HTML:
<head>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/jquery-3.4.1.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
</head>
<body>
<button id="click-button4">Attack</button>
<div id="dialog4">
<p>Which attack do you want to use?</p>
</div>
</body>
还有 JavaScript/jQuery:
$("#click-button4").click(function () {
$("#dialog4").css("display", "block");
$(function() {
$("#dialog4").dialog({
buttons: [
{
text: "Use sword",
click: function() {
console.log("Use sword");
}
},
{
text: "Slap him",
click: function() {
console.log("Slap him");
}
},
{
text: "Scream at him",
click: function() {
console.log("Scream at him");
}
},
]
}).dialog("widget").find(".ui-dialog-title").hide();
});
});
【问题讨论】:
-
您能否在您的 html 中为
dialog导入添加script和link标签?
标签: javascript jquery html button dialog