Is it possible to achieve two different navbars using Bootstrap 4.3.x as shown in the image below?
The first navbar (with "Sample Brand") fixed at the top, and the second navbar scrollable.
https://i.sstatic.net/mmm0P.png
I'm not certain if there is a built-in Bootstrap utility that can handle this specific layout.
I've attempted adding 'margin-top: 56px' to the second navbar to create space, but this workaround only works effectively on larger screens because of the height change when the burger menu icon appears on the first navbar.
Here is my current code:
<nav class="navbar navbar-expand-lg navbar-dark fixed-top" >
<div class="container">
<a class="navbar-brand" href="#">
Sample Brand
</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse flex-column" id="navbarResponsive">
<ul class="navbar-nav ml-auto">
<li class="nav-item active">
<a class="nav-link" href="#">Login
<span class="sr-only">(current)</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Register</a>
</li>
</ul>
</div>
</div>
</nav>
<nav class="navbar navbar-expand-lg navbar-dark p1-primary static-top" style="margin-top: 56px">
<div class="container">
<div class="collapse navbar-collapse" id="navbarResponsive">
<ul class="navbar-nav ">
<li class="nav-item active">
<a class="nav-link" href="#">Home
<span class="sr-only">(current)</span>
</a>
</li>
<li class="nav-item font-weight-lighter">
<a class="nav-link" href="#">FAQs</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Developer</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Contact Us</a>
</li>
</ul>
</div>
</div>
</nav>
This setup functions properly on large screens, but presents issues on smaller and medium-sized screens, as depicted here:
https://i.sstatic.net/zdke1.png
Determining the appropriate margin-top value is challenging due to the variable height of Bootstrap's navbar components.
If feasible, I prefer avoiding javascript solutions and instead seeking a css workaround (even though I may not be aware of it yet!). This is to avoid unnecessary complexity through JavaScript implementation. ๐