我尝试使用z-index使侧边栏与标题重叠,但我无法这样做。
header {
width: 100%;
height: 50px;
background-color: blue;
z-index: 0;
}
aside {
height: 100vh;
width: 300px;
background-color: green;
z-index: 200;
}

<body>
<header></header>
<aside></aside>
</body>
&#13;
答案 0 :(得分:3)
为position: absolute
.aside
header {
width: 100%;
height: 50px;
background-color: blue;
}
aside {
height: 100vh;
width: 300px;
position: absolute;
top: 0;
background-color: green;
}
&#13;
<body>
<header></header>
<aside></aside>
</body>
&#13;
答案 1 :(得分:1)
这类似于先前的问题。您是否尝试在侧边栏中使用负边距来改善重叠?
How to overlap sidebar on top of nav-bar
试试这个:
header {
width: 100%;
height: 50px;
background-color: blue;
z-index: 0;
}
aside {
height: 100vh;
width: 300px;
background-color: green;
margin: -50px;
z-index: 200;
}
答案 2 :(得分:0)
您可以添加position: absolute
aside {
height: 100vh;
width: 300px;
position: absolute;
background-color: green;
z-index: 200;
}