Bootstrap 3中的内联输入有问题

时间:2013-12-05 14:54:56

标签: html css twitter-bootstrap twitter-bootstrap-3

我无法找到一种可靠的方法让两个输入在this example内嵌显示:

<div class="row">
  <div class="col-md-8">
    <h3>Things</h3>
  </div>
  <div class="col-md-4">
    <form class="form-inline" role="form">
      <div class="input-group">
        <input type="search" class="form-control" placeholder="Search" />
        <span class="input-group-btn">
          <button class="btn btn-default" type="submit"><span class="glyphicon glyphicon-search"></span></button>
        </span>
      </div>
    </form>
    <a class="btn btn-primary pull-right" href="#/things/new">Add Thing</a>
  </div>
</div>

inputs here should be adjacent, right-aligned, and vertically-aligned with the H3 on the left.

当我将输入周围的div类设置为form-group(应该是)时,搜索输入停止向右看。

我可以通过将输入放在不同的网格列中来修复它,但是它们不能正确对齐。我希望它们彼此相邻并且右对齐,我希望它们与左侧的h3标签垂直对齐。

1 个答案:

答案 0 :(得分:2)

示例:http://jsbin.com/IRUciJe/1/

WITH RESPONSIVE TABLE:http://jsbin.com/IRUciJe/2/edit

input group form inline example}

<div class="row" role="search-row">
  <div class="col-xs-12 col-sm-5 col-md-5">
   <h3>Things</h3>
  </div>
  <div class="col-xs-12 col-sm-7 col-md-7">
   <form class="form-inline float-right" role="form">
    <div class="form-group">

     <!-- <input type="search" class="form-control" placeholder="Search + Enter" />-->

     <div class="input-group">
      <input type="search" class="form-control" placeholder="Search" />
      <span class="input-group-btn">
      <button class="btn btn-default" type="submit"><span class="glyphicon glyphicon-search"></span></button>
      </span>
     </div>
    </div>
    <!--/.form-group--> 

    <a class="btn btn-primary" href="#">Add Thing</a>
  </form>
  </div>
  <!--/.col-md-8-->

 </div>
 <!--/.row role=search-row-->

CSS

body { padding-top: 80px; }
hr.empty {margin:0 0 3% 0;border:0;}
div[role=search-row] h3 {margin:0 0 2%}

@media (min-width: 768px) {
div[role=search-row]  .float-right {float:right}
}