繁体   English   中英

如何使侧边栏与标题重叠?

[英]How to make sidebar overlap the header?

我尝试使用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> 

定义position: absolute .aside position: absolute

 header { width: 100%; height: 50px; background-color: blue; } aside { height: 100vh; width: 300px; position: absolute; top: 0; background-color: green; } 
 <body> <header></header> <aside></aside> </body> 

这类似于先前的问题。 您是否尝试在边栏上使用负边距来改善重叠?

如何在导航栏顶部重叠边栏

尝试这个:

header {

width: 100%;

height: 50px;

background-color: blue;

z-index: 0;

}


aside {

height: 100vh;

width: 300px;

background-color: green;

margin: -50px;

z-index: 200;

}

您可以添加position: absolute

aside {
  height: 100vh;
  width: 300px;
  position: absolute;
  background-color: green;
  z-index: 200;
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM