[英]Z-Index issues with DropDown Menu
When I hover over a menu, the menu li beneath is visible.当我将鼠标悬停在菜单上时,下方的菜单 li 可见。 It could be the div, but not sure.
它可能是 div,但不确定。 When I change to static and relative, they just shift down Here is my site http://ocart.site/opencart/
当我更改为静态和相对时,它们只是向下移动 这是我的网站http://ocart.site/opencart/
#menu > ul > li > div {
position: relative;
z-index: 5;
I have tried adding relative and a higher z-index, with no joy我尝试添加相对和更高的 z-index,但没有任何乐趣
You need to apply the following CSS rules:您需要应用以下 CSS 规则:
#menu > ul > li {
z-index: auto;
}
#menu > ul > li > a {
z-index: auto;
}
#menu > ul > li > div {
z-index: auto;
}
#menu > ul > li:hover > div {
z-index: 5;
}
Because you also define z-indexes on top level elements, the z-index which you refer to stop working.因为您还在顶级元素上定义了 z-index,所以您引用的 z-index 停止工作。
#menu > ul > li
and #menu > ul > li
#menu > ul > li
和#menu > ul > li
remove z-index declaration from them从中删除 z-index 声明
as other answer suggests , you can give them auto
value but its by default , so just remove it正如其他答案所暗示的那样,您可以给它们
auto
值,但默认情况下是它,所以只需将其删除
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.