Bootstrap表单组的间距错误

时间:2016-06-11 21:17:49

标签: css twitter-bootstrap

我在井元素中使用表单组,但是 底部可见边距超过顶部,这看起来不太好。我想让它垂直中心化。

<code>enter image description here</code>

<div class="well">
<div class="form-horizontal">
    <div class="form-group">
    ....
    <div class="form-group">
    ....
</div>
</div>

&#13;
&#13;
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<div class="well">

  <div id="date_formatter_widget">

    <!-- Widget -->

    <div class="form-horizontal">

      <div class="form-group">
        <div class="col-sm-9 text-right">
          <input type="text" class="form-control conversionPattern" id="pattern" placeholder="pattern here...">
        </div>
      </div>

      <div class="form-group">
        <div class="col-sm-12">
          <input type="text" class="form-control conversionPattern" id="conversionPattern" placeholder="" readonly value="2015-05-21">
        </div>
      </div>

    </div>

    <!-- /Widget -->

  </div>

</div>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:1)

.form-group的最后一个孩子有一个margin-bottom,可以通过以下方式将其删除:

.form-horizontal .form-group:last-child {margin-bottom: 0;}

.form-horizontal .form-group:last-child {
  margin-bottom: 0;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" />
<div class="well">

  <div id="date_formatter_widget">

    <!-- Widget -->

    <div class="form-horizontal">

      <div class="form-group">
        <div class="col-sm-9 text-right">
          <input type="text" class="form-control conversionPattern" id="pattern" placeholder="pattern here...">
        </div>
      </div>

      <div class="form-group">
        <div class="col-sm-12">
          <input type="text" class="form-control conversionPattern" id="conversionPattern" placeholder="" readonly value="2015-05-21">
        </div>
      </div>

    </div>

    <!-- /Widget -->

  </div>

</div>

预览

Preview