我的引导导航栏未显示在移动设备上

时间:2019-02-14 05:05:21

标签: javascript html css twitter-bootstrap navbar

我不知道为什么导航栏不会显示在移动设备上,但是在台式机上一切正常。
这里有我的代码:

    <div class="container">
        <nav class="navbar navbar-expand-lg navbar-light bg-light rounded font-weight-bold ">
            <div class="collapse navbar-collapse justify-content-center " id="navbarNav">
                <ul class="navbar-nav ">
                  <li class="nav-item">
                    <a class="nav-link" href="index.html">Home</a>
                  </li>
                  <li class="nav-item dropdown">
                    <a class="nav-link dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false">Results</a>
                    <div class="dropdown-menu">
                      <a class="dropdown-item" href="results/2019/January/January_2019.html">2019</a>
                    </div>
                  </li>
                  <li class="nav-item">
                    <a class="nav-link" href="standings/standings.html">Standings</a>
                  </li>
                  <li class="nav-item">
                    <a class="nav-link" href="about/about.html">About</a>
                  </li>
                </ul>
            </div>
        </nav>
    

1 个答案:

答案 0 :(得分:0)

在导航中包含导航栏切换按钮

像这样更新您的导航栏代码

<nav class="navbar navbar-expand-lg navbar-light bg-light rounded font-weight-bold ">

  <button class="navbar-toggler collapsed" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
      <span class="navbar-toggler-icon"></span>
    </button>


            <div class="collapse navbar-collapse justify-content-center " id="navbarNav">
                <ul class="navbar-nav ">
                  <li class="nav-item">
                    <a class="nav-link" href="index.html">Home</a>
                  </li>
                  <li class="nav-item dropdown">
                    <a class="nav-link dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false">Results</a>
                    <div class="dropdown-menu">
                      <a class="dropdown-item" href="results/2019/January/January_2019.html">2019</a>
                    </div>
                  </li>
                  <li class="nav-item">
                    <a class="nav-link" href="standings/standings.html">Standings</a>
                  </li>
                  <li class="nav-item">
                    <a class="nav-link" href="about/about.html">About</a>
                  </li>
                </ul>
            </div>
        </nav>