gpt4 book ai didi

css - z-index 不受尊重

转载 作者:技术小花猫 更新时间:2023-10-29 11:26:44 24 4
gpt4 key购买 nike

我有这样的风格:

header{
width:400px;
min-height:640px;
background:#9B9B76;
float:left;
z-index:1000; /*high*/
}
nav{
width:100%;
z-index:1001; /*highest*/
}

nav a{
float:left;
width:80%;
padding:10%;
font-size:20px;
}
nav a:hover{
background:#997548;
}
.LevelCnt_1{
float:left;
width:300px;
z-index:1; /*Lowest*/
position:absolute;
left:400px;
background:#baafa9;
}

问题是,如果我设置 left:0px

,视觉上 .LevelCnt_1 会停留在标题的顶部

为什么会这样?

最佳答案

z-index 仅适用于position relative, absolute & fixed。因此,将 position:relative 赋给您的 header & nav DIV。

像这样

header{
width:400px;
min-height:640px;
background:#9B9B76;
float:left;
z-index:1000; /*high*/
position:relative
}
nav{
width:100%;
z-index:1001; /*highest*/
position:relative
}

关于css - z-index 不受尊重,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8048441/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com