使用Twitter Bootstrap水平放置表单字段

Bil*_*lla 5 html css user-interface twitter-bootstrap

我们如何使用Twitter Bootstrap水平放置表单字段

我试过下面的HTML代码.但它如下所示逐一显示

  • 名字 - 文本框

  • 姓氏 - 文本框

    搜索

    <form class="form-horizontal">
        <div class="control-group">
          <label class="control-label" for="first">First Name</label>
          <div class="controls">
            <input type="text" id="first" placeholder="firstname">
          </div>
        </div>
        <div class="control-group">
          <label class="control-label" for="lastname">Last Name</label>
          <div class="controls">
            <input type="text" id="lastname" placeholder="Last Name">
          </div>
        </div>
        <div class="control-group">
          <div class="controls">              
            <button type="submit" class="btn">Search</button>
          </div>
        </div>
      </form>
    
    Run Code Online (Sandbox Code Playgroud)

我希望First Name和Last Name应该水平放置在第一行和下一行Search Button中.

像这样

  • 名字 - 文本框 姓氏 - 文本框

    搜索

小智 8

inline类添加到名字,姓氏control-groupdiv:

<div class="control-group inline">
Run Code Online (Sandbox Code Playgroud)

CSS

.inline {
    display:inline-block;
}
Run Code Online (Sandbox Code Playgroud)

工作小提琴http://jsfiddle.net/GgSRN/


mun*_*bir 7

试试这个

    <form class="form-group form-inline">
      <label class="control-label" for="first">First Name</label>
      <input type="text" id="first" placeholder="firstname">
      <label class="control-label" for="lastname">Last Name</label>
      <input type="text" id="lastname" placeholder="Last Name">

      <div>
        <button type="submit" class="btn">Search</button>
      </div>
    </form>
Run Code Online (Sandbox Code Playgroud)

检查bootstrap内联表格 如你所说的那样好.


Ale*_*ham 0

在单独的文件中使用 CSS 来设置 html 的样式。我亲自将它们包装在<div class="row">using Bootstrap 中,并为您想要创建的每一“行”使用其中一个。