管理多个交错图层时遇到一些困难。
I reproduced my issue in this Plunker example
<body>
<header>
<nav class="navbar">
<ul class="navbar-nav">
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="http://example.com" id="navbarDropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Dropdown link
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
<a class="dropdown-item" href="#">Action</a>
<a class="dropdown-item" href="#">Another action</a>
<a class="dropdown-item" href="#">Something else here</a>
</div>
</li>
</ul>
</nav>
</header>
<nav class="navbar row filter">
<form class="form-inline">
<input name="search" class="form-control" type="text" size="30"/>
</form>
</nav>
header {
background-repeat: no-repeat;
background-position: top center;
background-size: 100%;
position: relative;
height: 80px;
z-index: 100;
}
header .navbar {
padding:0;
}
.dropdown-menu {
z-index:300;
}
.filter {
margin-top:-20px;
background-color: black;
}
.filter form {
z-index:200;
}
如果我从最远的元素开始,我应该:
所以我指定了:
我不是css的专家,也许有更好的方法来实现这个设计,但我不明白为什么下拉菜单没有超过所有组件?
答案 0 :(得分:0)
简单:)你只需要调整header&amp;之间的z-index。导航栏。
header {
z-index: 301;
}
navbar{
z-index: 300;
}
玩得开心
编辑:在完全了解您的需求后,you can take a look at this