Navbar Toggler在Bootstrap 4上不起作用

我正在此导航栏上使用最新的引导程序4,我想在中小型屏幕上使用切换按钮。但是,该按钮不起作用并且没有显示菜单项。

包裹入(nav class =“ navbar navbar-expand-lg navbar-dark sticky-top”)

<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navigationCollapse">
    <span class="navbar-toggler-icon"></span>
</button>

<div class="collapse navbar-collapse" id="#navigationCollapse">
    <ul class="navbar-nav ml-auto">
        <li class="list-item">
            <a href="#" class="nav-link">Home</a>
        </li>
        <li class="list-item">
            <a href="#" class="nav-link">About</a>
        </li>
        <li class="list-item">
            <a href="#" class="nav-link">Services</a>
        </li>
        <li class="list-item">
            <a href="#" class="nav-link">Team</a>
        </li>
        <li class="list-item">
            <a href="#" class="nav-link">Contact</a>
        </li>
    </ul>
</div>
评论
  • mnam
    mnam 回复

    You need to make 2 changes - First, <li class="list-item"> to <li class="nav-item"> and second id="#navigationCollapse" to id="navigationCollapse". We use # only where we are referring to this id.

    Additionally i used <nav class="navbar navbar-expand-lg navbar-light sticky-top"> as nav.

    View JS Fiddle