Css 使用Z索引时防止导航栏展开
我发布了之前的一个问题。这个问题得到了回答,但现在却导致了意想不到的后果。起初,它阻止下拉菜单项出现在内容上方。我用Css 使用Z索引时防止导航栏展开,css,Css,我发布了之前的一个问题。这个问题得到了回答,但现在却导致了意想不到的后果。起初,它阻止下拉菜单项出现在内容上方。我用z-index:99999更新了下拉列表;位置:相对位置值以使其显示在内容上方,但现在它扩展了标题部分的高度。这里有3张图片 未选择的下拉列表: 它过去的样子: 现在如何使用z-index:99999;位置:相对位置 以下是导航栏的代码: <header> <div class="navbar navbar-inverse" id
z-index:99999更新了下拉列表;位置:相对位置代码>值以使其显示在内容上方,但现在它扩展了标题部分的高度。这里有3张图片
未选择的下拉列表:
它过去的样子:
现在如何使用z-index:99999;位置:相对位置代码>
以下是导航栏的代码:
<header>
<div class="navbar navbar-inverse" id="edadTopNavigation">
<div class="container-fluid app-navbar">
<div class="navbar-collapse collapse app-navbar-text-section">
<ul class="nav navbar-nav">
<li class="nav-item dropdown">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Index">Home</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" id="adminDropdownMenuLink" href='#' data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><div class="fa fa-cog"></div> Admin</a>
<div class="dropdown-menu" aria-labelledby="adminDropdownMenuLink">
<div>
<a class="nav-link text-dark" asp-area="" asp-controller="Acronym" asp-action="Index">Acronyms</a>
</div>
<div>
<a class="nav-link text-dark" asp-area="" asp-controller="User" asp-action="Index">Users</a>
</div>
<div>
<a class="nav-link text-dark" asp-area="" asp-controller="User" asp-action="Index">States</a>
</div>
<div>
<a class="nav-link text-dark" asp-area="" asp-controller="User" asp-action="Index">Countries</a>
</div>
</div>
</li>
</ul>
</div>
</div>
</div>
</header>
如何才能使下拉列表显示如图2而不是图3?您需要在下拉列表上使用绝对定位(或删除相对定位,如果它曾经工作过)@Pete如果我使用绝对定位(或删除相对定位),则菜单不会显示在主容器上方。
.navbar {
/* margin-bottom: 0px;*/
position: fixed; /* Set the navbar to fixed position */
top: 0; /* Position the navbar at the top of the page */
width: 100%;
overflow: hidden;
z-index: 200
}
.dropdown-menu {
padding: 10px;
background-color: #fff;
background-color: #fffff2;
z-index: 99999;
position: relative;
}