我正在使用bootstrap 4并且有一些我无法实现的东西。
我在顶部有一个简单的导航栏菜单,左边有一个徽标,右边有一个下拉菜单选择语言。在最常见的行为(桌面/笔记本电脑使用)看起来没问题(图1),屏幕右侧的徽标和语言选择器右侧的菜单链接,但是当您调整窗口大小(强制移动外观)和菜单折叠菜单框时在导航栏的中间(图2)但我想要实现的是当折叠的菜单框切换到最右边的屏幕并且在其左边的语言选择器下拉列表时。
我的代码:
<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>
有帮助吗?
谢谢。
使用flexbox排序(order-*
)类根据需要响应性地对齐项目...
<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