2016-11-28 92 views
0

我正在使用Bootstrap 3,我遇到了两个div之间的小差距问题。我曾试图弥补,但还是它不是在这里工作是我的代码两个div之间的小差距

.box1 { 
 
    background-color:black; 
 
    width:150px; 
 
    height:150px; 
 
    }
<div class="container"> 
 
<div class="row"> 
 
    <div class="col-md-1 col-md-offset-0"> 
 
     <div class="box1"> 
 

 
     </div> 
 
    </div> 
 
    <div class="col-md-1 col-md-offset-1"> 
 

 
<div class="box1"> 
 

 
     </div> 
 

 
    </div>  
 
</div> 
 
</div> 
 

的问题是,如果设置第二个div COL-MD-偏移0它太接近第一个div,如果我设置到1或者以上它设置了非常大的差距。我想非常小的差距

+0

您是否尝试过使用Bootstrap提供的'* -sm- *'(small)mods? – snkv

+0

是的,但不是更小的屏幕? – dast

+0

首先修复您的HTML,这不是有效的Bootstrap代码。 'row'只能在'container'里面,'col- *'只能在'row'里面。 – DavidG

回答

0

编辑:与山坳div的定制类名

尝试增加保证金。 像这样

<div class="container"> 
    <div class="row"> 
     <!-- custom-spacer is a custom class-name. to add extra margin. --> 
     <div class="col-md-1 col-md-offset-0 custom-spacer"> 
      <div class="box1"> 
      </div> 
     </div> 
     <div class="col-md-1 col-md-offset-1"> 
     </div> 
    </div> 
</div> 

<style> 
.box1 { 
    background-color:black; 
    width:150px; 
    height:150px; 
} 
.custom-spacer { 
    margin-right: 40px; /* Increase or decrease the margin as required. */ 
} 
</style> 

有可能是一个问题,这种做法,因为你增加了阴沟里的大小,你将无法在同一行内创建12周的cols。

+0

事实上填充不工作问题不是问题的缘由。 – dast