How to Center a column using Twitter Bootstrap?

How to Center a column using Twitter Bootstrap?

Asked on October 26, 2018 in Bootstrap.
Add Comment


  • 1 Answer(s)

    The first approach uses Bootstrap’s own offset classes so it requires no change in markup and no extra
    Cascading style sheet CSS. The key is to set an offset equal to half of the remaining size of the row. So for example, a column of size 2 would be centered by adding an offset of 5, that’s (12-2)/2.

    <div class="row">
        <div class="col-md-2 col-md-offset-5"></div>
    </div>
    

    Now, there’s an obvious drawback for this method, it only works for even column sizes, so only .col-X-2, .col-X-4, col-X-6, col-X-8 and col-X-10 are supported.

    Answered on October 26, 2018.
    Add Comment


  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.