Aki Aki - 1 year ago 129
CSS Question

Bootstrap: center any span

I have a problem when using a class to center my


.center {
margin-left: auto;
margin-right: auto;

<div class="row-fluid">
<div class="center span5">

This does not work, apparently it is overridden by bootstrap row-* CSS. However if I include the same style in the div directly (
) it works.

I think it doesn't work because it doesn't knows the width, so I tried to use an offset, but then when the button isn't centered as well as with the .CSS. I can't specify a width since my
width is set by external JavaScript.

How can I make the .center class work in that case?

Answer Source

As of Bootstrap 2.3.0 you can use the built in class .text-center.

<div class="row-fluid">

    <div class="span12 text-center">

    My content to be centered here



It worked perfectly for me... :)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download