Bootstrap 导航栏切换向上打开? Toggle 不会在点击时关闭?
Bootstrap Navbar Toggle Opens Upward? Toggle Won't Close On Click?
我正在使用 MDBootstrap(本质上是 Bootstrap 4)导航栏折叠,但是当点击一个元素时切换按钮不会折叠。我已经联系了 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>
不要在导航栏上设置高度。删除 style="height:70px;"
.
<nav class="navbar fixed-top navbar-expand-lg navbar-dark bg-dark scrolling-navbar">
<div class="container">
...
</div>
</nav>
我正在使用 MDBootstrap(本质上是 Bootstrap 4)导航栏折叠,但是当点击一个元素时切换按钮不会折叠。我已经联系了 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>
不要在导航栏上设置高度。删除 style="height:70px;"
.
<nav class="navbar fixed-top navbar-expand-lg navbar-dark bg-dark scrolling-navbar">
<div class="container">
...
</div>
</nav>