I'm working with bootstrap 4 and there is something I'm not being able to achieve.
I have a simple navbar menu on top with a logo at the left and a dropdown to select language at right. In the most common behaviour (desktop / laptop use) it looks ok (figure 1), menu links at right of logo and language selector at right of screen but when you resize window (to force mobile appearence) and menu collapse the menu box sticks to the middle of navbar (figure 2) but what I'd like to achieve is that when collapsed menu box switches to be at right-most of screen and immediately at its left the language selector dropdown.
My code:
<nav class="navbar navbar-expand-md bg-dark navbar-dark">
<!-- Brand -->
<a class="navbar-brand" href="https://www.cirsa.com/" target="_blank">
<img src="../../../assets/cirsa_logo.png" />
</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#collapsibleNavbar">
<span class="navbar-toggler-icon"></span>
</button>
<!-- Navbar links -->
<div class="collapse navbar-collapse" id="collapsibleNavbar">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
</ul>
</div>
<select class="selectpicker" data-width="auto" data-style="btn-primary" #langSelect (change)="cirsaApp.translate.use(langSelect.value)">
<option *ngFor="let lang of cirsaApp.translate.getLangs(); let i = index" [value]="lang" [selected]="lang === cirsaApp.translate.currentLang">{{cirsaApp._countries[i]}}</option>
</select>
</nav>
Any help?
Thanks.
Use the flexbox ordering (order-*
) classes to align the items responsively as needed...
<nav class="navbar navbar-expand-md bg-dark navbar-dark">
<a class="navbar-brand" href="https://www.cirsa.com/" target="_blank">
<img src="http://placehold.it/80x30" />
</a>
<button class="navbar-toggler order-last order-md-0" type="button" data-toggle="collapse" data-target="#collapsibleNavbar">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse order-last order-md-0" id="collapsibleNavbar">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
</ul>
</div>
<select class="selectpicker ml-auto" data-width="auto" data-style="btn-primary" #langSelect (change)="cirsaApp.translate.use(langSelect.value)">
<option *ngFor="let lang of cirsaApp.translate.getLangs(); let i = index" [value]="lang" [selected]="lang === cirsaApp.translate.currentLang">{{cirsaApp._countries[i]}}</option>
</select>
</nav>
https://www.codeply.com/go/acMidnkl1M