带有输入上方标签的内联引导程序表单

时间:2017-06-02 14:19:16

标签: html css twitter-bootstrap-3

如何在与其他文本字段相同的级别上向下移动搜索按钮?

enter image description here

  <form>
       <div class="col-md-3 form-group">
         <label for="search">Title</label>
         <input type="text" name="search" id="search" class="form-control" />
       </div>
       <div class="col-md-2 form-group">
         <label for="created_at_gt">Created at from</label>
         <input type="text" name="created_at_gt" id="created_at_gt" class="form-control" />
       </div>
       <div class="col-md-2 form-group">
         <label for="created_at_lt">To</label>
         <input type="text" name="created_at_lt" id="created_at_lt" class="form-control" />
       </div>
       <div class="row align-center">
         <input type="submit" value="search" class="btn btn-primary" />
        </div>
    </form>

3 个答案:

答案 0 :(得分:6)

一种简单的修复方法是添加与其他输入字段相同的结构(也可以避免添加可能无法涵盖所有​​情况的其他CSS),对于标签,使用&nbsp;作为占位符。

&#13;
&#13;
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<br><br><br><br><br><!-- ignore those br, just for stackoverflow full page view -->


<form>
  <div class="col-md-3 form-group">
    <label for="search">Title</label>
    <input type="text" name="search" id="search" class="form-control" />
  </div>
  <div class="col-md-2 form-group">
    <label for="created_at_gt">Created at from</label>
    <input type="text" name="created_at_gt" id="created_at_gt" class="form-control" />
  </div>
  <div class="col-md-2 form-group">
    <label for="created_at_lt">To</label>
    <input type="text" name="created_at_lt" id="created_at_lt" class="form-control" />
  </div>
  <div class="col-md-1 form-group align-center">
    <label for="created_at_lt">&nbsp;</label>
    <input type="submit" value="search" class="btn btn-primary form-control" />
  </div>
</form>
&#13;
&#13;
&#13;

答案 1 :(得分:1)

另一种简单的方法是将标签的高度添加为边距。

确保您进入整个网页摘要视图以查看正确的结果:

docker tag friendlyhello username/repository:tag
.lowered {
  margin-top: 25px;
}

答案 2 :(得分:1)

尝试在标签标签的末尾使用br标签

<div class="row">
<div class="col-md-6">
    <label for="search">Title</label><br>
    <input type="text" name="search" id="search" class="form-control" />
</div>
<div class="col-md-6">
    <label for="year">Year</label><br>
    <input type="text" name="year" id="year" class="form-control" />
</div>
</div>