我有一个正在使用Bootstrap 3.3.7的项目。我需要在导航栏中添加一个下拉菜单。
我以为自己的标记正确。但是,下拉菜单未按预期显示
这是我的代码
<nav class="navbar navbar-inverse navbar-fixed-top sticky-top" >
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="#">
Business Name
</a>
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav navbar-right">
<li class="dropdown notification-container">
<a href="#" class="nav-link dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
Notifications
<span class="notification-count badge">3</span>
</a>
<ul class="dropdown-menu dropdown-backdrop" style="width: 240px;">
<li class="p-2 border-bottom notification-message message-unread">
<a href="#"><small>Message 1</small></a>
</li>
<li class="p-2 border-bottom notification-message message-unread">
<a href="#"><small>Message 2</small></a>
</li>
<li class="p-2 border-bottom notification-message message-unread">
<a href="#"><small>Message 3</small></a>
</li>
</ul>
</li>
<li class="nav-item">
<div class="navbar-text mr-3 ml-1" style="margin-right: 12px; margin-left: 4px; "> Hello, Jake!</div>
</li>
</ul>
</div>
<!--/.navbar-collapse -->
</div>
</nav>
我还用代码创建了一个提琴手,以显示单击https://jsfiddle.net/tsjLhvz2/时右上方的通知菜单如何不显示项目
如何在导航栏中打开菜单?
答案 0 :(得分:1)
删除.dropdown-backdrop,出于某种原因,该类正在触发将您的列表从DOM中删除。