Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to align two col to the right? bootstrap 3 grid

I have three columns displayed in one row, I need to align last two to the right corner, it works fine with one column but when I try to pull-right two it messes up grid and pushes elements to the next row down. The question is how to align one column to the right and other next to it.

       <div class="row ">
                    <div class="col-sm-4">
                    ...
                    </div>

                    <div class="col-sm-3" >
                     ...
                    </div>

                    <div class="col-sm-5 pull-right">
                        <div class=" pull-right">
                          ...
                        </div>
                    </div>
        </div>

Current:

|[     ]       [      ]       [     ]|

Wanted:

|[     ]              [      ][     ]|
like image 299
user2998105 Avatar asked Mar 06 '14 22:03

user2998105


People also ask

How do I align columns to the right?

HTML | <col> align Attribute left: It sets the text left-align. right: It sets the text right-align. center: It sets the text center-align.

How do I align columns in Bootstrap?

To horizontally align columns, we can use the justify-content classes. justify-content-start left align the columns. justify-content-center center aligns the columns. justify-content-end right align the columns.

Which one is used to move columns to the right in grid in Bootstrap?

Offset classes Move columns to the right using .offset-md-* classes. These classes increase the left margin of a column by * columns. For example, .offset-md-4 moves .col-md-4 over four columns.


1 Answers

It depends on whether you're right aligning text inside the middle column, or some another container inside the column.. Here are a few examples that may work for you..

http://www.bootply.com/119747

<div class="row ">
  <div class="col-sm-4">
    1 text here 
  </div>
  <div class="col-sm-3 text-right">
    2 text here 
  </div>
  <div class="col-sm-5">
    3 text here 
  </div>
</div>

<div class="row ">
  <div class="col-sm-4">
    <div class="well"> 
      content
    </div>
  </div>
  <div class="col-sm-3">
    <div class="well pull-right"> 
      content pull-right 
    </div>
  </div>
  <div class="col-sm-5">
    <div class="well"> 
      content
    </div>
  </div>
</div>
like image 124
Zim Avatar answered Sep 19 '22 13:09

Zim