【发布时间】:2018-06-10 09:54:58
【问题描述】:
我正在制作一个 jQuery UI 对话框。它看起来非常好,而且我的样式很有效,但是对话框中的第一段元素很大。
CSS 没有设置字体以外的任何内容。如果我添加max-height: 1.5em;,那么它们就会像下面这样堆叠在一起。
我不知道这是做什么的,但我的代码如下。我有一种感觉,这是由于页面上其他地方的内容迫使元素移动。
#cadEditor {
display: none;
z-index: 999999 !important;
background: #222;
}
.ui-dialog {
background: #222;
}
.ui-dialog .ui-dialog-titlebar {
background: #333;
height: 40px;
top: 0;
text-align: center;
line-height: 40px;
}
.ui-dialog .ui-dialog-title {
position: absolute;
top: 0;
display: block;
width: 100%;
height: fit-content;
text-align: center;
}
#cadEditor p {
max-height: 1.5em;
}
.ui-dialog .ui-dialog-titlebar-close {
display: none;
}
.ui-dialog .ui-button {
color: #fff;
background: #222;
padding: 0.3em 0.5em;
border: #000000 1px solid;
border-radius: 5px;
margin: 1em;
cursor: pointer;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js"></script>
<div id="cadEditor">
<p>Test Dialog</p>
<p>Test Dialog</p>
<p>Test Dialog</p>
<p>Test Dialog</p>
<p>Test Dialog</p>
<p>Test Dialog</p>
<p>Test Dialog</p>
<p>Test Dialog</p>
<p>Test Dialog</p>
<p>Test Dialog</p>
</div>
<script>
function showCadEditor(button) {
$('#cadEditor').dialog({
dialogClass: "cadEditorDialog",
autoOpen: true,
title: "Editing Cad " + $(button).attr("forcad"),
modal: true,
resizable: false,
width: 600,
buttons: {
"Save": function () {
$(this).dialog("close");
},
"Cancel": function () {
$(this).dialog("close");
}
}
});
return false;
}
showCadEditor();
</script>
【问题讨论】:
-
删除代码片段示例中的最大高度时,它看起来仍然很好。你能验证一下并与你的原始代码进行比较吗?如果是,并且您的原件仍然存在问题,您能否提供原件的链接?
-
令人讨厌的是,我无法提供链接,因为该网站受密码保护。该对话框独立工作,但在网站本身中不起作用,这就是我认为内容会影响它的原因。