I'm trying to align a button to the right inside my nav and I can't.
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
<div class="container-fluid">
<div class="card">
<div class="card-header">
Cabecera
</div>
<div class="card-body">
<div id="principal">
<div class="row">
<div class="col">
<nav class="navbar fixed-bottom navbar-dark bg-dark">
<button type="button" id="addParte" class="btn btn-outline-success float-right "><i class="fa fa-plus-circle" aria-hidden="true"></i> Parte</button>
</nav>
</div>
</div>
</div>
</div>
</div>
</div>
To align elements to the right inside a
navbar
, Bootstrap has a class.ml-auto
that applies to lists<ul>
, this is possible using Flexbox .What this class does is "nudge" elements to the right by assigning an auto-margin to the left.
The class
.float-right
does not work for you because it conflicts with elements in Flex delnavbar
, Bootstrap itself recommends you to be careful with it .Is this nav going to have something other than the button, such as a list of items? Because if you are only going to put the button I think it is better to do it in a div and not in a nav.