我正在使用Bootstrap 3.0,似乎无法弄清楚如何在面板之间添加填充/空格。
<div class="row">
<div class="col-xs-4 panel">
<div class="panel-body">
<h4>First Cell</h4>
</div>
</div>
<div class="col-xs-4 panel">
<div class="panel-body">
<h4>Second Cell</h4>
</div>
</div>
<div class="col-xs-4 panel">
<div class="panel-body">
<h4>Third Cell</h4>
</div>
</div>
</div>
我尝试添加一个类并将宽度设置为30%,但只有当你有两个面板并将其拉到右边时它才有效。如果我添加一个边距,那么它会关闭响应,最后一个单元格会下降到下一行。
我如何相应地在面板之间添加间隙?
答案 0 :(得分:21)
我倾向于不合并.panel和.col *:
http://jsfiddle.net/isherwood/xTc7a/1/
<div class="row">
<div class="col-xs-4">
<div class=" panel">
<div class="panel-body">
<h4>First Cell</h4>
</div>
</div>
</div>
<div class="col-xs-4">
<div class=" panel">
<div class="panel-body">
<h4>Second Cell</h4>
</div>
</div>
</div>
<div class="col-xs-4">
<div class=" panel">
<div class="panel-body">
<h4>Third Cell</h4>
</div>
</div>
</div>
</div>
答案 1 :(得分:3)
更改html如下,
<div class="row">
<div class="col-xs-4">
<div class="panel">
<div class="panel-body">
<h4>First Cell</h4>
</div>
</div>
</div>
<div class="col-xs-4">
<div class="panel">
<div class="panel-body">
<h4>Second Cell</h4>
</div>
</div>
</div>
<div class="col-xs-4">
<div class="panel">
<div class="panel-body">
<h4>Third Cell</h4>
</div>
</div>
</div>
</div>
答案 2 :(得分:2)
您可以像这样使用并根据需要划分为任意数量的列。
<div class="row">
<div class="col-md-6">
<div class="col-md-12">
<div class=" panel">
<div class="panel-body">
<h4>First Cell</h4>
</div>
</div>
</div>
</div>
<div class="col-md-6">
<div class="col-md-12">
<div class=" panel">
<div class="panel-body">
<h4>Second Cell</h4>
</div>
</div>
</div>
</div>
</div>
答案 3 :(得分:0)
我设法通过在前两个面板中添加一个类panel-4来实现这个目的:
.panel-4 {
width:30%;
margin-right:5%;
}