Mobile app version of vmapp.org
Login or Join
Cooney921

: Bootstrap navbar with collapsed menu icon On this bootstrap starter template: when the browser gets narrow the navigation bar links/buttons collapse into one icon in top-right corner like this:

@Cooney921

Posted in: #Bootstrap #Html

On this bootstrap starter template:



when the browser gets narrow the navigation bar links/buttons collapse into one icon in top-right corner like this:



I would like to have this collapsed "icon" as default like on the picture above. So that the navbar links are available after the user clicks that top-right collapsed button.

How to do that?

This is the source code of the template:

<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<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="#">Project name</a>
</div>
<div id="navbar" class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li class="active"><a href="#">Home</a></li>
<li><a href="#about">About</a></li>
<li><a href="#contact">Contact</a></li>
</ul>
</div><!--/.nav-collapse -->
</div>
</nav>

<div class="container">

<div class="starter-template">
<h1>Bootstrap starter template</h1>
<p class="lead">Use this document as a way to quickly start any new project.<br> All you get is this text and a mostly barebones HTML document.</p>
</div>

</div><!-- /.container -->

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Cooney921

1 Comments

Sorted by latest first Latest Oldest Best

 

@Chiappetta492

I don't think this is the place for these types of questions, you should use stackoverflow.

However one way to deal with this is to edit the bootsrap source file. On line 4321 of bootstrap.css you will find the following:
@media (min-width: 768px) {
.navbar-toggle {
display: none;
}
}


Change the above media query to display the navbar-toggle (which is the button) at whatever screen size you want.

From the bootstrap definition:
Device Width Container Width
1200px or higher 1170px (large screens - large desktops)
992px to 1199px 970px (medium screens - small desktops/laptops)
768px to 991px 750px (small screens - tablets)
Less than 768px auto (extra small screens - phones)


You may have to make some other changes, but I don't have time to sift through what those are because I'm on my way out the door, but this should at least show you where to look. You could also just overwrite this in your style.css with the !important tag.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme