1
Hello, I am using bootstrap version 4.0 beta-2, and I have a question, how do I close the navbar menu after clicking on a list item? By default you need to click on the item and click again in the menu to close.
I found a solution for this on the Internet, but it was all using old versions of Bootstrap, and apparently it doesn’t work on my.o'.
code
<nav class="navbar navbar-expand-lg navbar-dark bg-default">
<span class="navbar-brand" align = "center">
<h2 class = "font-weight-light text-justify"><em>A s t r o </em> mania</h2>
</span>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarText" aria-controls="navbarText" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarText">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a class="nav-link" href="#Inicio">Home<span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Features</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Pricing</a>
</li>
</ul>
<span class="navbar-text" align = "center">
O melhor counteúdo de astronomia você encontra aqui no <em>A s t r o</em> mania.
</span>
</div>
</nav>
Note: This is when it is on smaller screens, when it adapts to smaller screens and the Nav-bar menu "icon" appears...
– Yuri Gabriel
When you click on an item in the menu, it does not refresh the page?
– Sam
No, do not reload, it just directs to the link target... and the target is on the page itself, so it just redirects to the content and does not close the menu alone...
– Yuri Gabriel
Seeing the first link in the list the "Start", my idea was to leave fixed this navbar, and when the user was browsing down and wanted to go back up, just click on the menu, and click on the "Start". The problem is that after clikcar it does not close alone
– Yuri Gabriel
See if the answer helped.
– Sam