gpt4 book ai didi

css - 将导航栏 bootstrap 4 向右对齐

转载 作者:太空宇宙 更新时间:2023-11-04 01:57:31 26 4
gpt4 key购买 nike

我正在尝试将新版本的 Bootstrap 用于个人元素。我试图制作一个导航栏,我希望链接向右对齐,我寻找了一个解决方案,但我找不到如何去做。这是我的代码

<nav class="navbar navbar-toggleable-md navbar-light bg-faded">
<button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse"
data-target="#navbarNavAltMarkup" aria-controls="navbarNavAltMarkup" aria-expanded="false"
aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<a class="navbar-brand" href="#">taïho sushi</a>
<div class="collapse navbar-collapse" id="navbarNavAltMarkup">
<div class="navbar-nav">
<a class="nav-item nav-link active" href="#">Présentation</a>
<a class="nav-item nav-link" href="#">Menu</a>
<a class="nav-item nav-link" href="#">Contact</a>
</div>
</div>
</nav>

最佳答案

使用新的 ml-auto 类设置 margin-left:auto 并将内容推到右边。

<nav class="navbar navbar-toggleable-md navbar-light bg-faded">
<button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse"
data-target="#navbarNavAltMarkup" aria-controls="navbarNavAltMarkup" aria-expanded="false"
aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<a class="navbar-brand" href="#">taïho sushi</a>
<div class="collapse navbar-collapse" id="navbarNavAltMarkup">
<div class="navbar-nav ml-auto">
<a class="nav-item nav-link active" href="#">Présentation</a>
<a class="nav-item nav-link" href="#">Menu</a>
<a class="nav-item nav-link" href="#">Contact</a>
</div>
</div>
</nav>

Demo on Codeply

关于css - 将导航栏 bootstrap 4 向右对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42330670/

26 4 0