Right align text within Bootstrap 4 breadcrumbs

Update 2018 Bootstrap 4.1

float-* doesn’t work with flexbox.

The better way to align breadcrumbs items to the right now that Bootstrap 4 is flexbox is to use auto-margins. Simply don’t make the last item a breadcrumb-item to remove the divider and ml-auto to push it to the right.

<nav aria-label="breadcrumb">
    <ol class="breadcrumb">
        <li class="breadcrumb-item"><a href="#">Home</a></li>
        <li class="breadcrumb-item"><a href="#">Library</a></li>
        <li class="breadcrumb-item active">Data</li>
        <li class="ml-auto">Basket</li>
    </ol>
</nav>

EDIT:

“How about if I have two <li>‘s that I want to right aligned? If I use
two <li class="ml-auto">Basket</li>, one is in the middle.”

In that case you would just use ml-auto on the leftmost (first) of the 2 li‘s.

https://www.codeply.com/go/6ITgrV7pvL

Leave a Comment