Twitter bootstrap 在twitter引导中居中对齐列
我已经开始学习Bootstrap。我的问题是如何水平居中对齐列,引导包含12列布局,没有中间数字。更清楚的是,如果是11列布局,中间的数字应该是6(左5列,中1列,右5列)使用bootstrap 3,实现所需的最佳方法是……使用偏移列。有关更多详细信息,请参见以下示例:Twitter bootstrap 在twitter引导中居中对齐列,twitter-bootstrap,alignment,Twitter Bootstrap,Alignment,我已经开始学习Bootstrap。我的问题是如何水平居中对齐列,引导包含12列布局,没有中间数字。更清楚的是,如果是11列布局,中间的数字应该是6(左5列,中1列,右5列)使用bootstrap 3,实现所需的最佳方法是……使用偏移列。有关更多详细信息,请参见以下示例: 简言之,在不使用任何自定义类的情况下,这里的示例可能会有所帮助。只需注意“col-6”是如何使用的,其中有一半是3…因此使用了“offset-3”。平均拆分将允许您选择的居中的间距: <div class="contai
简言之,在不使用任何自定义类的情况下,这里的示例可能会有所帮助。只需注意“col-6”是如何使用的,其中有一半是3…因此使用了“offset-3”。平均拆分将允许您选择的居中的间距:
<div class="container">
<div class="col-sm-6 col-sm-offset-3">
your centered, floating column
</div></div>
你的中心,浮动列
这里正确回答了这个问题
对于奇数行:即col-md-7或col-large-9使用此
将居中列添加到要居中的列
<div class="col-lg-11 col-centered">
对于偶数行:即col-md-6或col-large-10,使用此
只需使用bootstrap3的offset col类。i、 e
<div class="col-lg-10 col-lg-offset-1">
<代码> > p>如果你不能放置1列,你可以简单地在中间放置2列。
(我只是把答案组合起来)
用于引导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>
此外,还有另一个解决方案我尝试了上面给出的方法,但当一个列中的内容高度动态增加时,这些方法失败,基本上会将其他列向下推
对我来说,基本的表格布局解决方案奏效了
// 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;
}
我以前尝试过这种方法,但奇数列不起作用。仅供参考,最新的引导会导致重叠偏移量会占用空间,如果您希望内容以col-lg-10为中心,并且占用的空间超过col-lg-10,则这种方法不起作用
.col-centered{
display: block;
margin-left: auto;
margin-right: auto;
text-align: center;
}
// 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;
}