Reputation: 21
I have checked out similar answers to this question and have set up my code similar to this response here, but still cannot get it to work:
bootstrap 3 navbar collapse button not working
I even tried using the exact code for the default navbar
on the Bootstrap 3 site, but it still doesn't work.
I've included these two links in the head section and my paths are correct:
http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css http://netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"
My relevant code:
<nav class="navbar navbar-default navbar-fixed-top navbar-inverse role"="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".nav-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Brand</a>
</div>
<div class="collapse navbar-collapse" id="nav-collapse">
<ul class="nav navbar-nav navbar-right">
<li><a href="#about">About</a></li>
<li><a href="#reviews">Reviews</a></li>
<li><a href="#contact">Contact</a></li>
</ul>
</div>
</div>
</nav>
Upvotes: 2
Views: 6986
Reputation: 11665
You've made a couple of small errors which is why the button doesn't work:
1) You have a typo on the <nav>
element with a misplaced quote at navbar-inverse role"="navigation"
2) Your data-target
for the button should be #nav-collapse
since it's an id and not a class.
That's it, here's the working version.
Upvotes: 1
Reputation: 36
Make sure you included the latest jQuery library and Bootstrap's javascript file.
Upvotes: 0