Bootstrap搜索表单布局

时间:2016-08-01 20:41:05

标签: twitter-bootstrap

我无法通过右对齐按钮获取Bootstrap来渲染简单的全宽搜索输入。这是我的代码:

<div class="row">
    <div class="col-md-12">
        <form class="form-inline">
            <input type="search" class="form-control" id="search" placeholder="I wish this would work...">
            <button type="button" class="btn btn-primary">Search</button>
        </form>
    </div>
</div>

所有这些都包含在container

2 个答案:

答案 0 :(得分:0)

pull-right添加到您的类字符串

class="btn btn-primary pull-right"

答案 1 :(得分:0)

您可以尝试:

<div class="container">
  <form class="form-inline row">
    <div class="col-xs-8">
      <input type="search" class="form-control" id="search" placeholder="I wish this would work...">
    </div>
    <div class="col-xs-4">
      <button type="button" class="btn btn-primary btn-block">Search</button>
    </div>
  </form>
</div>

以下是一个完整的示例:https://jsfiddle.net/v8rm9nx4/3/