Changing Menu Order on Collapsed Navbar in Bootstrap 3
I ran into a similar issue but have been using Bootstrap 4.4 and this can be solved with a simple d-none d-block solution.
<ul class="nav justify-content-center">
<li class="nav-item d-sm-none d-md-block">
<a class="nav-link" href="#">Item 1</a>
</li>
<li class="nav-item d-sm-none d-md-block">
<a class="nav-link" href="#">Item 2</a>
</li>
<li>
<li class="nav-item">
<a class="nav-link" href="#">Item 3</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Item 4</a>
</li>
<li class="nav-item d-none d-sm-block d-md-none">
<a class="nav-link" href="#">Item 1</a>
</li>
<li class="nav-item d-none d-sm-block d-md-none">
<a class="nav-link" href="#">Item 2</a>
</li>
</ul>
Using this method allows for items 1 and 2 to only appear after the display is set to small and below. While also hiding the originals at that same display size.
I ended up finding a simpler solution for the reformatting and reordering of the button links on the collapsed navbar, one that doesn't require new javascript code:
<div class="collapse navbar-collapse navHeaderCollapse">
<ul class="nav navbar-nav navbar-right hidden-xs">
<li><a href="#" class="btn navbar-btn" id="Btn_1">Button One</a></li>
<li><a href="#" class="btn navbar-btn" id="Btn_2">Button Two</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li><a href="#">Item1</a></li>
<li><a href="#">Item2</a></li>
<li><a href="#">Item3</a></li>
<li><a href="#">Item4</a></li>
</ul>
<ul class="nav navbar-nav visible-xs">
<li><a href="#" >Button One</a></li>
<li><a href="#" >Button Two</a></li>
</ul>
</div>
I simply duplicated the Button One and Button Two <ul>
section and added it to the bottom. I then removed the classes and ID on the <a>
links so that no button formatting would occur. Finally, I added the hidden-xs
bootstrap class to the top <ul>
and visible-xs
to the bottom <ul>
class. That did the trick: