我在封面div内有菜单div,当我尝试点击它时我不能。我也尝试使用z-index:-1作为封面,没有任何反应。当我把一些东西从封面div中取出时我可以点击它。
#cover {
position:relative;
margin:auto;
width:100%;
height:800px;
z-index: -1;
background-image: url('pozadinaa.png');
background-size: cover;
}
#meni {
position:absolute;
width: auto;
font-size:50px;
cursor:pointer;
color:white;
right:4%;
top:5%;
}
答案 0 :(得分:0)
删除z-index
(您为#cover
设置此项,因此#menu
也受此影响。)
#cover {
position: relative;
margin: auto;
width: 100%;
height: 200px;
background-image: url('pozadinaa.png');
background-size: cover;
}
#cover.zindex {
z-index: -1;
}
#menu {
position: absolute;
width: auto;
font-size: 50px;
cursor: pointer;
color: white;
right: 4%;
top: 5%;
}
<h1>Clickable</h1>
<div id="cover">cover
<div id="menu">
<a href="#">link1</a>
<a href="#">link2</a>
<a href="#">link3</a>
</div>
</div>
<h1>Not clickable (z-index = -1)</h1>
<div id="cover" class="zindex">cover
<div id="menu">
<a href="#">link1</a>
<a href="#">link2</a>
<a href="#">link3</a>
</div>
</div>