Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to horizontally center align a row of bootstrap spans that don't add up to 12?

<div class="row">
  <div class="span4"></div>
  <div class="span4"></div>
</div>

I understand that you need 12 spans in total. Is there a way to still center align the two spans I have horizontally? The above will just float to the left.

I've tried putting a wrapper around them and margin auto'ng it but nothing happens.

I can go and remove the span class and just add a specified width but I need span class for fluid layout.

like image 468
meiryo Avatar asked Apr 11 '13 07:04

meiryo


1 Answers

If you want to center two columns of span4 you can use offset param like this:

<div class="row">
  <div class="span4 offset2"></div>
  <div class="span4"></div>
</div>

Remember this may crash in lower resolutions. To prevent that think about using fluid grid layout. This is done by changing

<div class="row">

into

<div class="row-fluid">

Hope that helps!

like image 192
Dmonix Avatar answered Sep 23 '22 18:09

Dmonix