Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap columns stacking vertically and not horizontally

I have a row divided into 3 columns using col-sm-4. Now i expect this row to be divided horizontally into three parts. But it's divided vertically.

See on Jsfillde

Here's my code

<div class="container">
    <div class="row"  style="padding:13px 15px;">
        <div class="pull-left span4">
            <a href=""><img src="themes/custom/img/logo.png" width="120" alt="logo"/></a>
        </div>
        <div class="pull-right span4">
            <div class="row">
                <div class="col-sm-4">One</div>
                <div class="col-sm-4">Two</div>
                <div class="col-sm-4">Three</div>
            </div>
        </div>
    </div>
</div>

I have kept a logo on the left side and on the right side there is a row that i want to divide horizontally in 3 parts.

What am i doing wrong?

like image 248
Kanav Avatar asked Mar 14 '15 10:03

Kanav


People also ask

How do I make column vertical in Bootstrap?

One way to vertically center is to use my-auto . This will center the element within it's flexbox container (The Bootstrap 4 . row is display:flex ). For example, h-100 makes the row full height, and my-auto will vertically center the col-sm-12 column.

Do Bootstrap columns need to be in a row?

Yes, you need to use row. The row > col relationship is the same in both Bootstrap 3 and 4 in that..

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.

Why Bootstrap divided the grid into 12 imaginary columns?

Well, a 12-column layout was how Bootstrap developed their layout technique. It is more effective because the layout was only intended to grow as large as the body of the page and shrink as small as a few words.


2 Answers

Your code works just fine. The .col-sm-* classes are applied for width 768px and above. If you want make this three divs always horizontally, you have to use classes .col-xs-4 in your case. Updated jsfiddle

Futher reading - http://getbootstrap.com/css/#grid-options

like image 132
Indy Avatar answered Oct 01 '22 12:10

Indy


I was having the same problem and was at my wits end. Then I refreshed the browser and it worked.

like image 40
MisterO Avatar answered Oct 01 '22 13:10

MisterO