Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap col align right

I'm trying to create a row with 2 cols. One col on the left with its contents aligned left, and the second col with its contents aligned right (old pull-right).

How to do I go about this in alpha-6?

I've tried a few things, but this is what I have so far. What am I missing?

<div class="row">     <div class="col">left</div>     <div class="col ml-auto">content needs to be right aligned</div> </div> 
like image 545
Thibs Avatar asked Feb 24 '17 15:02

Thibs


People also ask

How do I align text to the right in Bootstrap?

You can simply use the class . justify-content-between in combination with the class . d-flex to left align and right align text content within a <div> container in Bootstrap 4.

How do I center COL in Bootstrap?

To center the column horizontally or vertically use Flexbox utilities. Add . d-flex . justify-content-center classes to the parent element of the column (it should be .


2 Answers

Bootstrap 5 (update 2021)

To right align elements in Bootstrap 5...

float-right is now float-end
text-right is now text-end
ml-auto is now ms-auto

Bootstrap 4 (original answer)

Use float-right for block elements, or text-right for inline elements:

<div class="row">      <div class="col">left</div>      <div class="col text-right">inline content needs to be right aligned</div> </div> <div class="row">       <div class="col">left</div>       <div class="col">           <div class="float-right">element needs to be right aligned</div>       </div> </div> 

http://codeply.com/go/oPTBdCw1JV

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 the Bootstrap 4 .row, Card or Nav. The ml-auto (margin-left:auto) is used in a flexbox element to push elements to the right.

Bootstrap 4 align right examples

like image 98
Zim Avatar answered Oct 12 '22 13:10

Zim


How about this? Bootstrap 4

<div class="row justify-content-end">     <div class="col-3">         The content is positioned as if there was         "col-9" classed div appending this one.     </div> </div> 
like image 45
Bexultan Myrzatay Avatar answered Oct 12 '22 14:10

Bexultan Myrzatay