gpt4 book ai didi

css - z-index 不适用于我的下拉菜单

转载 作者:行者123 更新时间:2023-11-28 19:19:44 24 4
gpt4 key购买 nike

<分区>

我有一个导航栏,下拉菜单是绝对定位的,但出于某种原因,它们仍然出现在所有其他定位元素的后面,无论 z-index 是什么。这使得菜单既难看又难以在带有定位项的页面上使用。 Here is a codepen显示我的导航栏和它遇到的问题。有谁知道出了什么问题吗?

这是我的 css 的一小部分,因为我认为您不希望我的问题中有完整的 150 行代码:

header nav ul li ul {
background-color: #00242b;
transition: opacity 400ms ease-in;
opacity: 0;
position: absolute;
height: 0px;
z-index: 1000000000; /* why wont this work? */
overflow: auto;
transform: translate(0px, 0px);
overflow: auto;
}
#absolute { /* this is on top despite the lower z-index */
position: absolute;
width: 80px;
height: 40px;
background-color: red;
z-index: 0;
left: 20px;
top: 80px;
}

24 4 0