I want to use the Twitter Bootstrap to layout my navbar so that there is "left", "middle" and "right" parts to it, where the middle part gets collapsed down under the navbar-toggler
("burger menu") when there's not enough space.
Codepen for a self-contained example: https://codepen.io/fiver/pen/eKJOMG
The part I have wrong (I think) is the definiton of the "icon" elements:
<nav className="navbar navbar-expand-sm navbar-dark bg-dark ">
<a className="navbar-brand" href="#">ExampleApp</a>
<button className="navbar-toggler" type="button"
data-toggle="collapse"
data-target="#navbarNav" >
<span className="navbar-toggler-icon"/>
</button>
<a className="navbar-brand navbar-right" href="#">Icon1</a>
<div id="navbarNav" className="collapse navbar-collapse" >
<ul className="navbar-nav">
<li nav items></li>
....
</ul>
</div>
<a className="navbar-brand navbar-right" href="#">Icon2</a>
</nav>
When there's enough horizontal space that the navbar-toggle is not needed, Icon1
is in the wrong place:
But when the navbar-toggler
is active, and the menu is expanded, Icon2
is in the wrong place:
At the moment, I'm only planning on having one of the Icon
menu items in my app. I'm just using two here to illustrate the different behaviour when I put the icon in the two different places.
Note both placements seem to work the way I want when the navbar-toggler
menu is active, but collapsed:
What do I need to do to make the icon act like Icon2
when there's lots of space navbar-toggler
and Icon1
when space is constrained?