Bootstrap形式水平对齐不起作用?

时间:2017-11-11 13:28:59

标签: twitter-bootstrap

我希望我的电子邮件和密码出现在同一行,但它不起作用。请帮我。

 <div class="container">
                  <form >
                      <fieldset class="form-group row">
                          <label for="email" class="control-label col-sm-2">Email</label>
                          <div class="col-sm-10">
                                <input type="email" class="form-control" id="email" />
                          </div>
                      </fieldset>
                      <fieldset class="form-group row">
                          <label for="password" class="control-label col-sm-2">Password</label>
                          <div class="col-sm-10">
                            <input type="password" id="password" class="form-control" />
                          </div>
                      </fieldset>
                      <fieldset class="form-group">
                          <button type="submit" class="btn btn-primary">Submit</button>                  
                      </fieldset>
                  </form>
              </div>

2 个答案:

答案 0 :(得分:-1)

确保您的代码是这样的

<form class="form-horizontal" role="form">
 <div class="form-group">
 <label for="firstname" class="col-sm-2 control-label">First Name</label>
 <div class="col-sm-10">
 <input type="text" class="form-control" id="firstname"
 placeholder="Enter First Name">
 </div>
 </div>
 <div class="form-group">
 <label for="lastname" class="col-sm-2 control-label">Last Name</label>
 <div class="col-sm-10">
 <input type="text" class="form-control" id="lastname"
 placeholder="Enter Last Name">
 </div>
 </div>
 <div class="form-group">
 <div class="col-sm-offset-2 col-sm-10">
 <div class="checkbox">
 <label>
 <input type="checkbox"> Remember me
 </label>
 </div>
 </div>
 </div>
 <div class="form-group">
 <div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-default">Sign in</button>
 </div>
 </div>
</form>

答案 1 :(得分:-1)

{{1}}