本文翻译自:Bootstrap 4 align navbar items to the right
How do I align a navbar item to right? 如何将导航栏项目右对齐?
I want to have the login and register to the right. 我要登录并在右边注册。 But everything I try does not seem to work. 但是我尝试的所有方法似乎都无法正常工作。
This is what I have tried so far: 到目前为止,这是我尝试过的:
-
<div>
around the<ul>
with the atribute:style="float: right"
<div>
周围,<ul>
带有属性:style="float: right"
-
<div>
around the<ul>
with the atribute:style="text-align: right"
<div>
在<ul>
<div>
周围,带有属性:style="text-align: right"
- tried those two things on the
<li>
tags 在<li>
标记上尝试了这两件事 - tried all those things again with
!important
added to the end 再次尝试所有这些事情,最后添加!important
- changed
nav-item
tonav-right
in the<li>
在<li>
nav-right
nav-item
更改为nav-right
- added a
pull-sm-right
class to the<li>
在<li>
添加了pull-sm-right
类 - added a
align-content-end
class to the<li>
在<li>
添加了align-content-end
类
This is my code: 这是我的代码:
<div id="app" class="container">
<nav class="navbar navbar-toggleable-md navbar-light bg-faded">
<button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarNavDropdown" aria-controls="navbarNavDropdown" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<a class="navbar-brand" href="#">Navbar</a>
<ul class="navbar-nav">
<li class="nav-item active">
<a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link&#