How to center Bootstrap columns when they are an odd number?

后端 未结 3 2141
长情又很酷
长情又很酷 2020-12-30 03:35

I am creating an image slider using Bootstrap and having an issue that I can\'t seem to solve in my head.

Under each instance of this slider, I will have 3-column th

3条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-30 03:46

    Bootstrap 4: Center Odd Columns

    I know the original question was Bootstrap 3.x timeframe, but now that 4.x is available centering odd numbers of columns is easier. Here's an example of 5 equal, full-width columns (no extra CSS) using the new auto-layout grid..

    1
    2
    3
    4
    5

    http://www.codeply.com/go/MJTglTsq9h

    This solution works because Bootstrap 4 is now flexbox, and also works for any number of odd columns across the viewport.

    You can also center the "classic grid" columns that have defined width using justify-content-center on the row. For example, 5 col-sm-2 columns...

提交回复
热议问题