如何在bootstrap中为div div中的div设置margin

时间:2016-08-12 04:41:30

标签: html css html5 twitter-bootstrap

如何在bootstrap中的div div中设置div的余量,就像我试图使保证金5px的代码一样,但它不起作用!

<div class="container bg_red">          
        <h1>Test DIV boxes</h1>
        <div class="row">
            <div class="col-md-3 thin_border bg_green">
                <div class="bg_blue">
                Some content here for panel 1       
                </div>
            </div>
            <div class="col-md-9 thin_border">
                Some content here for panel 2
            </div>
        </div>                      
    </div>

1 个答案:

答案 0 :(得分:2)

这是你想要的吗?检查添加到一个div而不是另一个div的margin-5类,以便您可以看到差异。

.thin_border {
  border: 1px solid #EFEFEF;
}
.margin-5{
  margin: 5px;
 }
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<div class="container bg_red">
  <h1>Test DIV boxes</h1>
  <div class="row">
    <div class="col-md-3 thin_border bg_green">
      <div class="bg_blue margin-5">
        Some content here for panel 1
      </div>
    </div>
    <div class="col-md-9 thin_border">
      Some content here for panel 2
    </div>
  </div>
</div>