How do you properly align right a toolbar in Bootstrap?
Asked Answered
C

3

7

When you have a toolbar with a few buttons and a drop down, like this one:

<div class="container">
    <div class="btn-toolbar" role="toolbar">
        <div class="btn-group"><a class="btn btn-default" role="button" href="">Invite People</a></div>
        <div class="btn-group"><a class="btn btn-default" role="button" href="">Create Campaign</a></div>
        <div class="btn-group"><a class="btn btn-default" role="button" href="">Edit</a></div>
        <div class="btn-group">
            <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-expanded="false">Action <span class="caret"></span></button>
            <ul class="dropdown-menu" role="menu">
                <li><a href="#">Action</a></li>
                <li><a href="#">Another action</a></li>
                <li><a href="#">Something else here</a></li>
            </ul>
        </div>
    </div>
</div>

How do you properly align it right? I tried pull-right on the toolbar as well as the button groups as well as one button group with pull-right containing all the buttons. None of those worked.

Corduroys answered 15/4, 2015 at 8:49 Comment(3)
hope pull-right is working jsfiddle.net/9uym374g/2.. anything else you are expecting?Breskin
the class Pull-right should fix your problem.Phila
Yes, you are right, pull-right at the toolbar level works. I am not sure what made it fail before. Probably I never tried pull-right and one button group per button at the same time (as the whole one button group per button feels silly).Corduroys
B
10

Try like this: DEMO

<div class="container">
    <div class="btn-toolbar pull-right" role="toolbar">
.....
</div></div>

Bootstrap pull-right is working fine here.

Breskin answered 15/4, 2015 at 10:27 Comment(2)
this does not work in bootstrap 4, pull right has been changed to float-rightBivalent
They changed it again in Bootstrap 5, now it's float-endArgentiferous
D
0

In Bootstrap 5.3.2, I'm using justify-content-end since no other suggestion above works.

Example: https://jsfiddle.net/chdaL9k0/1/

Differentiation answered 6/12, 2023 at 8:46 Comment(0)
H
-1

You can simply add the class 'pull-right' to .btn-toolbar, or in your css file, just give your toolbar the float right property like so:

.btn-toolbar {
  float: right;
  }
Hoban answered 15/4, 2015 at 9:29 Comment(2)
This does not work per se. It will make your toolbar fully float to the right, changing its expected properties. In any case, you could apply the "float: right" to buttons inside a toolbar, overriding the "float:left" property that make them float left.Tokyo
You can edit your answer to include this so someone coming after us find the proper response.Tokyo

© 2022 - 2025 — McMap. All rights reserved.