中心alignmenttwitter引导中的一列

我已经开始学习Bootstrap了。 我的问题是如何居中alignment一列,bootstrap包含12列布局,没有中间数字。 如果是11列布局,则中间数为6(左边5列,右边1列,右边5列)

这个问题是正确的答案在这里使用Twitter的Bootstrap 3中心一列

对于奇数行:即col-md-7或col-large-9使用此行

将col-centered添加到要居中的列。

<div class="col-lg-11 col-centered"> 

并将其添加到您的样式表中:

 .col-centered{ float: none; margin: 0 auto; } 

对于偶数行:即,col-md-6或col-large-10使用此行

只需使用引导3的偏移col类。 即

 <div class="col-lg-10 col-lg-offset-1"> 

用bootstrap 3来实现你想要的是最好的方式是… 抵消列 。 请看这些例子的更多细节:
http://getbootstrap.com/css/#grid-offsetting

总之,没有看到你的div这里是一个例子,可以帮助,而不使用任何自定义类。 只要注意如何使用“ col-6 ”,以及如何使用“ col-6 ”的一半是3 …所以使用“ 偏移-3 ”。 同样的分割将允许你要的中心间距:

 <div class="container"> <div class="col-sm-6 col-sm-offset-3"> your centered, floating column </div></div> 

如果你不能把1列,你可以简单地把2列在中间…(我只是合并答案)对于Bootstrap 3

 <div class="row"> <div class="col-lg-5 ">5 columns left</div> <div class="col-lg-2 col-centered">2 column middle</div> <div class="col-lg-5">5 columns right</div> </div> 

甚至,你可以通过添加到样式文本居中的列:

 .col-centered{ display: block; margin-left: auto; margin-right: auto; text-align: center; } 

另外,这里还有另一个解决scheme

我尝试了上面给出的方法,但是这些方法在dynamic增加其中一个列的内容的高度时失败,它基本上将其他列降低。

对我来说,基本的表格布局解决scheme工作

 // Apply this to the enclosing row .row-centered { text-align: center; display: table-row; } // Apply this to the cols within the row .col-centered { display: table-cell; float: none; vertical-align: top; }