我有两个div,一个header和一个section,section总是占据整个屏幕,header只占一小部分。
在我的section中,我有一个链接,您可以在下面的代码中看到:
* {
margin: 0;
padding: 0;
}
#header {
width: 100%;
background: green;
height: 50px;
z-index: 1;
}
#section {
background: yellow;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
overflow: hidden;
float: left;
z-index: -1;<div id="header">This is my header</div>
<div id="section">
<br>
<br>
<br>
<br><a href="#">Go to the link</a>
</div>
我需要在我的z-index中使用header,因为如果我不使用,它就不会出现,因为section覆盖了整个屏幕。
您可以看到演示这里
在我将代码放入JSFiddle之前,我的问题是我无法单击section中的链接,但是在将代码放入JSFiddle之后,该链接正在工作。
为什么会发生这种情况?如何在我的网站上解决这个问题?
发布于 2016-04-19 15:29:37
您能否只更新CSS以不使用z索引,并将背景色应用于正文标记?JS Fiddle。
*{
margin:0;
padding:0;
}
body {
background:yellow;
}
#header{
width:100%;
background:green;
height:50px;
}
#section{
// Intentionally blank
}https://stackoverflow.com/questions/36722688
复制相似问题