Is it possible to have multiple fixed-top navbars in Bootstrap 4 showing under each other?
The 1 currently overlays the other which is not what I want.
Is it possible to have multiple fixed-top navbars in Bootstrap 4 showing under each other?
The 1 currently overlays the other which is not what I want.
Yes, it's possible but you have to position the 2nd one accordingly. The height of the Navbar is ~56px.
.fixed-top-2 {
margin-top: 56px;
}
body {
padding-top: 105px;
}
<nav class="navbar navbar-toggleable-sm bg-faded navbar-light fixed-top fixed-top-2">
<button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbar1">
<span class="navbar-toggler-icon"></span>
</button>
<a href="/" class="navbar-brand">One</a>
<div class="navbar-collapse collapse" id="navbar1">
<ul class="navbar-nav">
..
</ul>
</div>
</nav>
<nav class="navbar navbar-toggleable-sm bg-inverse navbar-inverse fixed-top">
<button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbar2">
<span class="navbar-toggler-icon"></span>
</button>
<a href="/" class="navbar-brand">Two</a>
<div class="navbar-collapse collapse" id="navbar2">
<ul class="navbar-nav">
..
</ul>
</div>
</nav>
Demo: Bootstrap 4 Multiple fixed-top Navbars
In some scenarios, it may be better to use a single fixed-top
DIV to contain both.
Also see: Bootstrap 4 Navbar sticky after header