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?
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.
Yes, you need to use row. The row > col relationship is the same in both Bootstrap 3 and 4 in that..
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.
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.
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
I was having the same problem and was at my wits end. Then I refreshed the browser and it worked.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With