Boostrap 4 Navbar Collapse Menu Right Align
Just use "text-right" in HTML
For example:
<div class="navbar-collapse text-right" id="navbarResponsive">
Just add simple rule to your css.
.nav-item{
text-align: right;
}
According to http://getbootstrap.com/docs/4.0/components/navs/#horizontal-alignment, the way to center, right-justify, or left-justify things in the navbar's collapsed dropdown is to use justify-content-end
and friends in the class
of a nav
.
Example. This code yields the image following it.
<nav class="navbar navbar-expand-lg fixed-top">
<div class="container">
<!-- Brand and toggle get grouped for better mobile display -->
<ul class="list-inline social-buttons">
{% for link in site.social %}
<li class="list-inline-item">
<a href="{{ link.url }}"><i class="{{ link.icon }}"></i></a>
</li>
{% endfor %}
</ul>
<div class="navbar-toggler" data-toggle="collapse" data-target="#menu">
☰<!-- three bars symbol -->
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="menu">
<ul class="nav ml-auto">
<a class="nav-link page-scroll" href="#about">About</a>
<a class="nav-link page-scroll" href="#projects">Projects</a>
<a class="nav-link page-scroll" href="#writing">Writing</a>
<a class="nav-link page-scroll" href="#contact">Contact</a>
</ul>
</div>
</div>
</nav>
Now amending that one line to:
<div class="nav ml-auto justify-content-end">
yields
Note this evidently has nothing to do with ml-auto
, which when missing causes the uncollapsed menu items (on a wider screen) to not be right-justified. (The toggler button itself is always right justified for me.) Only justify
seems to control the stuff in the uncollapsed menu.