问题描述
在 jQuery 对话框中显示自动建议框时出现问题.无论如何,自动建议列表都会显示在对话框下方.我尝试将 autosuggest 的 z-index 属性设置为 > 1004.但没有运气.
I have a problem displaying the autosuggest box inside a jQuery dialog. The auto suggest list is displayed under the dialog no matter what. I have tried setting up the z-index property of autosuggest to > 1004. But no luck.
下面是截图.
这是我用来设置自动建议列表样式的 CSS 类:
This is the CSS class I have used to style the autosuggest list:
ul.as-list {
position: absolute;
list-style-type: none;
margin: 2px 0 0 0;
padding: 0;
font-size: 14px;
color: #000;
font-family: "Lucida Grande", arial, sans-serif;
background-color: #fff;
background-color: rgba(255,255,255,0.95);
box-shadow: 0 2px 12px #222;
-webkit-box-shadow: 0 2px 12px #222;
-moz-box-shadow: 0 2px 12px #222;
border-radius: 5px;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
z-index:6000;
}
li.as-result-item, li.as-message {
margin: 0 0 0 0;
padding: 5px 12px;
background-color: transparent;
border: 1px solid #fff;
border-bottom: 1px solid #ddd;
cursor: pointer;
border-radius: 5px;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
z-index:6000;
}
我已经在 jsfiddle 页面上传了完整的代码.你可以清楚地看到那里的问题.我该如何解决?
I have uploaded the complete code in this jsfiddle page. You can see the problem there clearly. How can I fix it?
推荐答案
根本原因是最外面的两个元素有overflow: hidden
.
The root cause is that the outermost two elements have overflow: hidden
.
解决这个问题的最简单方法是:
The simplest way to fix that is:
.ui-dialog, .ui-dialog-content {
overflow: visible !important
}
如果你对使用 !important
不满意(这不是好的做法),你可以找到 overflow: hidden
实际应用的地方,并修复它在那里.
If you're not happy with using !important
(it's not good practise), you can find the place where overflow: hidden
is actually being applied, and fix it there.
快速修复版本:http://jsfiddle.net/mNQVr/(在 Chrome、Firefox、IE 中测试过)
这篇关于jQuery 对话框中的 Z-index.自动建议列表未正确显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!