Z-index in jQuery dialog. Autosuggest list not displayed properly(jQuery 对话框中的 Z-index.自动建议列表未正确显示)
问题描述
在 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.自动建议列表未正确显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:jQuery 对话框中的 Z-index.自动建议列表未正确显示


- Fetch API 如何获取响应体? 2022-01-01
- Css:将嵌套元素定位在父元素边界之外一点 2022-09-07
- Quasar 2+Apollo:错误:找不到ID为默认的Apollo客户端。如果您在组件设置之外,请使用ProvideApolloClient() 2022-01-01
- 使用RSelum从网站(报纸档案)中抓取多个网页 2022-09-06
- 400或500级别的HTTP响应 2022-01-01
- 如何使用 JSON 格式的 jQuery AJAX 从 .cfm 页面输出查 2022-01-01
- addEventListener 在 IE 11 中不起作用 2022-01-01
- Flexslider 箭头未正确显示 2022-01-01
- 失败的 Canvas 360 jquery 插件 2022-01-01
- CSS媒体查询(最大高度)不起作用,但为什么? 2022-01-01