我正在使用bootstrap,我有一行包含动态数量的col-sm-3 div。我希望在行内有这样的col-sm-3 divs会居中,而不是左对齐
这是一些示例代码:
<div class="custom-fields row custom-field-output">
<div class="row">
<div class="col-sm-3">
content 1
</div>
<div class="col-sm-3">
content 2
</div>
</div>
</div>
我想让两个col-sm-3 div在行div中水平居中。
答案 0 :(得分:0)
试试这段代码:
<div class="custom-fields row custom-field-output">
<div class="row col col-sm-12">
<div class="col col-sm-3 col-offset-3">
content 1
</div>
<div class="col col-sm-3 ">
content 2
</div>
</div>
</div>
答案 1 :(得分:0)
尝试以下操作,并检查此来源:http://getbootstrap.com/css/#grid-example-basic
<div class="custom-fields row custom-field-output">
<div class="row">
<div class="col-sm-6">
content 1
</div>
<div class="col-sm-6">
content 2
</div>
</div>
答案 2 :(得分:0)
<div class="custom-fields row custom-field-output">
<div class="row">
<div class="col-sm-4 col-sm-offset-4">
content 1
</div>
<div class="col-sm-4 col-sm-offset-4">
content 2
</div>
</div>
此代码将用于保持左右边距相同..
答案 3 :(得分:0)
试试这段代码:
<div class="custom-fields row custom-field-output">
<div class="row">
<div class="col-sm-3"><div>
<div class="col-sm-3">
content 1
</div>
<div class="col-sm-3">
content 2
</div>
<div class="col-sm-3"></div>
</div>
</div>
答案 4 :(得分:0)
这个很晚,但我相信这是你要做的事情:
<div class="custom-fields row custom-field-output">
<div class="row">
<div class="col-sm-3 col-sm-offset-3">
content 1
</div>
<div class="col-sm-3">
content 2
</div>
</div>
</div>