Right align element in div class
Bootstrap 5 (update 2021)
Because of new RTL support, *-left
and *-right
classes have changed to *-start
and *-end
. Here are the Bootstrap 4 to Bootstrap 5 conversions:
float-left
=>float-start
float-right
=>float-end
ml-auto
=>ms-auto
mr-auto
=>me-auto
Bootstrap 4 (original answer)
In Bootstrap 4, pull-right
has been replaced with float-right
.
If float-right
is not working, remember that Bootstrap 4 is now flexbox, and many elements are display:flex
which can prevent float-right
from working. In some cases, the utility classes like align-self-end
or ml-auto
work to right align elements that are inside a flexbox container like a Bootstrap 4 .row, Card or Nav. The ml-auto
(margin-left:auto) is used in a flexbox element to push elements to the right.
Also, remember that text-right
still works on inline elements.
Bootstrap 4 align right examples
I've removed the class pull-right
class from both the button
and the p
tag and added text-right
class to the div.container
.
I think this is what you need.
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.1.1.slim.min.js" integrity="sha384-A7FZj7v+d/sdmMqp/nOQwliLvUsJfDHW+k9Omg/a/EheAdgtzNs3hpfag6Ed950n" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js" integrity="sha384-DztdAPBWPRXSA/3eYEEUWrWCy7G5KFbe8fFjk5JAIxUYHKkDx6Qin1DkWx51bBrb" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js" integrity="sha384-vBWWzlZJ8ea9aCX4pEW3rVHjgjt7zpkNpZk+02D9phzyeVkE+jo0ieGizqPLForn" crossorigin="anonymous"></script>
<div class="container text-right">
<p class="d-inline">Some text</p>
<button type="button" class="btn btn-primary d-inline">+</button>
</div>