Bootstrap Navbar Toggle向上打开?点击后切换不会关闭?

时间:2018-03-25 04:49:28

标签: html bootstrap-4 mdbootstrap

我正在使用MDBootstrap(基本上是Bootstrap 4)Navbar Collapse,但是单击元素时切换按钮不会折叠。我自己联系了MDBootstrap,似乎无法得到答案。我被告知要使用Angular,但我使用的是JQuery,我读过你不应该把它们混合在一起。另外,我不知道如何将Angular合并到我的网站中。我之前使用过Bootstrap,并且从来没有使用过Angular,只需点击一下就可以关闭切换按钮。这听起来对任何人都很熟悉吗?

最后,当我点击切换按钮时,它向上打开而不是向下 - 任何人都可以帮助它,我希望它向下打开。

我的代码在这里:

  <nav class="navbar fixed-top navbar-expand-lg navbar-dark scrolling-navbar" style="height: 70px;">
    <div class="container">

      <!-- Brand -->
      <a class="navbar-brand" href="index.php"><img src="img/andrea1.jpg" class="rounded-circle img-fluid">
      </a>


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

    <!-- Links -->
    <div class="collapse navbar-collapse text-center" id="navbarSupportedContent">
      <!-- Left -->
      <ul class="navbar-nav mr-auto">
        <li class="nav-item">
          <a class="nav-link" href="#about">About
            <span class="sr-only">(current)</span>
          </a>
        </li>
        <li class="nav-item">
          <a class="nav-link" href="#port">Portfolio</a>
        </li>       

</ul>
      <!-- Right -->
      <ul class="navbar-nav nav-flex-icons">
        <li class="nav-item">
          <a href="https://www.linkedin.com/in/andreasanchez2/" class="nav-link" target="_blank" title="Follow on LinkedIn">
            <i class="fa fa-linkedin"></i>
          </a> 
        </li>
        <li class="nav-item">
          <a href="https://github.com/dec23rd1986"  class="nav-link" target="_blank" title="Follow on Github">
            <i class="fa fa-github"></i>
          </a> 
        </li>
        <li class="nav-item">
          <a href="https://twitter.com/dec23rd1986" class="nav-link" target="_blank" title="Follow on Twitter">
            <i class="fa fa-twitter"></i>
          </a> 
        </li>

        <li class="nav-item">
          <a href="#contact" class="nav-link" title="Contact">
            <i class="fa fa-envelope mr-3"></i>
          </a>
        </li>
      </ul>

    </div>

  </div>
</nav>

1 个答案:

答案 0 :(得分:0)

不要在导航栏上设置高度。删除style="height:70px;"

<nav class="navbar fixed-top navbar-expand-lg navbar-dark bg-dark scrolling-navbar">
    <div class="container">
    ...
    </div>
</nav>

Working as expected