我正在尝试使用Bootstrap显示彼此相邻的两个div,但它们之间有一段距离。我怎样才能将它们完全放在一起。
代码:
<div class="col-lg-8 col-lg-offset-2 centered">
<div style="float: left; border: 1px solid; width: 227px; height: 50px;"></div>
<div style="float: right; border: 1px solid;width: 227px; height: 50px;"></div>
</div>
图片说明:
答案 0 :(得分:21)
在Bootstrap中查看grids。
你可以这样做:
<div class="row">
<div class="col-xs-6">div 1</div>
<div class="col-xs-6">div 2</div>
</div>
答案 1 :(得分:3)
添加到Lschessinger的答案中,您可以使用偏移来使块居中。在抵消列
下查看here也许这就是你要找的东西?
<style>
.border {border: 1px solid #CCC;}
</style>
<div class="row">
<div class="col-xs-2 border col-xs-offset-4">div 1</div>
<div class="col-xs-2 border">div 2</div>
</div>
或者如果您必须坚持使用内联样式和特定宽度的代码,那么可以通过将宽度增加454px到464px来增加宽度,以获得10px的间隙,依此类推:
<div class="col-lg-12">
<div style="width: 454px;" class="center-block">
<div style="border: 1px solid; width: 227px; height: 50px;" class="pull-left"></div>
<div style="border: 1px solid; width: 227px; height: 50px;" class="pull-right"></div>
</div>
</div>