jonbon jonbon - 4 months ago 17
HTML Question

Bootstrap CSS menu won't open when collapsed

I'm using Pico CMS. Here is the navigation code

<!-- Navigation -->
<nav class="navbar navbar-default navbar-custom navbar-fixed-top">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header page-scroll">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#collapseID">
<span class="sr-only">Toggle navigation</span>
Menu <i class="fa fa-bars"></i>
</button>
<a class="navbar-brand" href="#">Broadstone Services</a>
</div>

<!-- Collect the nav links, forms, and other content for toggling -->
<div class="navbar-collapse collapse" id="collapseID">
<ul class="nav navbar-nav navbar-right">
<li>
<a href="/">Home</a>
</li>
<li>
<a href="about">About</a>
</li>
<li>
<a href="solutions">Solutions</a>
</li>
<li>
<a href="contact">Contact</a>
</li>
<li>
<a href="blog">Blog</a>
</li>

</ul>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container -->
</nav>


When my page is full screen, the menu items look great. However, when the page window is made a lot smaller (or on mobile) the menu doesn't expand.

Answer

You are not loading the jQuery and Bootstrap JavaScript libraries that perform the functional uncollapse.

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" crossorigin="anonymous"></script>

See http://getbootstrap.com/getting-started/

For functional reference see: https://github.com/twbs/bootstrap/blob/master/dist/js/bootstrap.js#L557