即使我已将“navbar-right”类添加到ul标记,我的导航栏项也未对齐。我做错了什么?
<nav class="navbar navbar-expand-lg fixed-top navbar-dark bg-dark justify-content-between">
<div class="container">
<div class="navbar-header">
<a class="navbar-brand" href="#"><strong>My Name</strong></a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button></div>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="nav navbar-nav navbar-right">
<li class="nav-item">
<a class="nav-link" href="#">About
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Portfolio</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Contact</a>
</li>
</ul>
</div></div>
</nav>
答案 0 :(得分:0)
在打开div
标记后,不要将container
与nav
类同时使用,navbar
的内容将与右侧对齐。
要将ul
的内容与右侧对齐,请使用ml-auto