在bootstrap中彼此相邻的2 div

use*_*384 6 html css twitter-bootstrap

我试图使用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>
Run Code Online (Sandbox Code Playgroud)

图示:

在此输入图像描述

lsc*_*ger 21

查看Bootstrap中的网格.

你可以这样做:

<div class="row">
    <div class="col-xs-6">div 1</div>
    <div class="col-xs-6">div 2</div>
</div>
Run Code Online (Sandbox Code Playgroud)


mjw*_*tts 5

添加到 Lschessinger 的答案中,您可以使用偏移量将块居中。在偏移列下查看此处

也许这就是你要找的?

<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>
Run Code Online (Sandbox Code Playgroud)

或者,如果您必须坚持使用内联样式和特定宽度的代码,那么您可以通过将宽度 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>
Run Code Online (Sandbox Code Playgroud)