I have a Bootstrap 3 navbar. When I scale the browser window to a low resolution or access the page with my mobile I have no menu. Usually, with Bootstrap I have a collapsed navigation but it is nowhere to be found.
Here is the HTML:
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<a class="navbar-brand" href="index.php"><img src="images/logo.png"></a>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav navbar-right">
<li><a href="index.php">Home</a></li>
<li class="aktiv" ><a href="advertiser.php">Advertisers</a></li>
<li><a href="publisher.php">Publishers</a></li>
<li><a href="#" data-toggle="modal" data-target="#aboutModal">About</a></li>
<li><a href="#" data-toggle="modal" data-target="#pressModal">Press</a></li>
</ul>
</div>
</div>
</nav>
CSS:
.navbar {
background-color: #333E48;
border: 0;
display: block!important; /* From Stack Overflow */
}
.navbar-brand > img,
.navbar-brand {
padding:0px;
margin:0;
}
.navbar-brand > img {
padding: 4px;
height: 50px;
margin: auto;
vertical-align: middle;
display: inline-block;
}
.navbar-brand,
.navbar-nav li a {
line-height: 90px;
height: 90px;
padding-top: 0px;
}
.nav-collapse.collapse {
height: auto !important; /* From Stack Overflow */
overflow: visible !important; /* From Stack Overflow */
}
I added display: block!important;
to .navbar
after reading Nav disappears after resize
I added height: auto !important; overflow: visible !important;
to .nav-collapse.collapse
after reading Twitter bootstrap responsive navigation disappears after opening and closing
Issue still persists.
2
Answers
Just have to remove the
collapse
class ondiv#navbar
Here is a fiddle
And rewrite the css for the xs view
It isn’t clear in your question but your missing the toggle button to open and close the menu when your viewport is reduced, otherwise the mobile menu will always be open.