Reputation: 628
I know that is a frequent question but I'm running a fever and it's costing me to make this thing work:
<nav class="navbar navbar-default navbar-fixed-top small-screen">
<div class="container-fluid">
<div class="navbar-header" style="border-bottom: 1px solid #dedede; width: 100%">
<a class="navbar-brand top-logo"><img src="img/any.jpg" alt="MRT"/></a>
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-right2">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div id="menor" class="collapse navbar-right2">
<ul>
<li><div class="active">Index</div></li>
<li><div class="inactive"><a 01.php">One</a></div></li>
<li><div class="inactive"><a href="02.php">Two</a></div></li>
<li><div class="inactive"><a href="03.php">Three</a></div></li>
<li><div class="inactive"><a href="#contact">CONTACT</a></div></li>
</ul>
</div>
I have had to add the contact form to the footer so now I need to hide the nav after clicking "Contact".
I did try several solutions found here in Stackoverflow but none is working.
Any tip will be appreciated.
Upvotes: 0
Views: 34
Reputation: 33933
If you want that "contact" link to behave exactly as the button that toggles the navigation, just add data-toggle="collapse" data-target=".navbar-right2"
to that contact link...
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
<nav class="navbar navbar-default navbar-fixed-top small-screen">
<div class="container-fluid">
<div class="navbar-header" style="border-bottom: 1px solid #dedede; width: 100%">
<a class="navbar-brand top-logo"><img src="img/any.jpg" alt="MRT"/></a>
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-right2">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div id="menor" class="collapse navbar-right2">
<ul>
<li><div class="active">Index</div></li>
<li><div class="inactive"><a href="01.php">One</a></div></li>
<li><div class="inactive"><a href="02.php">Two</a></div></li>
<li><div class="inactive"><a href="03.php">Three</a></div></li>
<li><div class="inactive"><a href="#contact" data-toggle="collapse" data-target=".navbar-right2">CONTACT</a></div></li>
</ul>
</div>
Upvotes: 1