html - Bootstrap 3 中的内联输入问题

标签 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 标签垂直对齐。

最佳答案

样本:http://jsbin.com/IRUciJe/1/

带有响应表: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}
}

关于html - Bootstrap 3 中的内联输入问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20403192/

相关文章:

javascript - 为什么 JQuery .html() 不适用于单个 div 标签?

javascript - Google 应用程序脚本,不能包含 css

css - Material Design/Materialize 3列列表

css - 填充在 Chrome 中返回不同的结果

html - 如何解决 z-index 问题?

html - 我页面的标签和文本框的对齐方式

javascript - JavaScript 对象字面量中的单引号

html - 重用 SVG 图像,同时保持 CSS 控制

twitter - 实现 Twitter Bootstrap 模式

html - Bootstrap 破坏多级菜单