Twitter的Bootstrap - 创建一个包含2列的表单

Cod*_*008 32 html css twitter-bootstrap

是否可以使用twitter bootstrap创建两列形式?他们在这里有一些很好的例子:http: //twitter.github.com/bootstrap/base-css.html 但不幸的是他们所有人都在使用一列.

Cho*_*rds 50

将表单标记包裹在span div中.这对我有用,但你可能需要稍微调整一下:

<div class="row">
  <form class="form-horizontal">
    <div class="span6">
      <fieldset>
      <legend>Legend text</legend>
      <div class="control-group">
        <label class="control-label" for="input01">Text input</label>
        <div class="controls">
          <input type="text" class="input-xlarge" id="input01">
          <p class="help-block">Supporting help text</p>
        </div>
      </div>
      </fieldset>
    </div>
    <div class="span6">
      <fieldset>
        <legend>Legend text</legend>
        <div class="control-group">
          <label class="control-label" for="input01">Text input</label>
          <div class="controls">
            <input type="text" class="input-xlarge" id="input01">
            <p class="help-block">Supporting help text</p>
          </div>
        </div>
      </fieldset>
    </div>
  </form>
</div>
Run Code Online (Sandbox Code Playgroud)

  • 我实际上发现这在流畅的布局中不能很好地工作.由于某种原因,缩小屏幕大小时文本字段会重叠.它发生在第二个跨度包裹到下面一行之前. (5认同)

fsi*_*ons 10

<div class="row">
    <div class="span12">
        <div class="row-fluid">
            <div class="span6">
                <label>First Name</label>
                <input type="text" class="span12" placeholder="">
            </div>
            <div class="span6">
                <label>Last Name</label>
                <input type="text" class="span12" placeholder="Type something…">
            </div>
        </div>
    </div>
</div>
Run Code Online (Sandbox Code Playgroud)

例如:http://jsfiddle.net/JJnDg/460/


Ero*_*lin 9

Bootstrap 3中的2列:

http://jsfiddle.net/52VtD/10419/

<div class="container">
    <div class="row">
        <form action="#">
            <div class="col-xs-6">
                <div class="form-group">
                    <label for="firstname">Firstname</label>
                    <input type="text" class="form-control" id="firstname" placeholder="Firstname">
                </div>
                <div class="form-group">
                    <label for="email">Email</label>
                    <input type="email" class="form-control" id="email" placeholder="example@domain.com">
                </div>
                <button type="submit" class="btn btn-default">Submit</button>
            </div>
            <div class="col-xs-6">
                <div class="form-group">
                    <label for="lastname">Last Name</label>
                    <input type="text" class="form-control" id="lastname" placeholder="Last Name">
                </div>
                <div class="form-group">
                    <label for="password">Password</label>
                    <input type="password" class="form-control" id="password" placeholder="Password">
                </div>
            </div>
        </form>
    </div>
</div>
Run Code Online (Sandbox Code Playgroud)