使用bootstrap 3中的输入对齐按钮

时间:2017-05-27 17:03:17

标签: html5 twitter-bootstrap-3

我需要将button与输入字段对齐。

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<form>
   <div class="form-group col-lg-6">
      <label for="email">Nome:</label>
      <input type="email" class="form-control" id="email">
   </div>
   <div class="form-group col-lg-6">
      <label for="pwd">CNPJ:</label>
      <input type="password" class="form-control" id="pwd">
   </div>
   <div class="input-group-btn">
      <button type="submit" class="btn btn-default">Submit</button>    
   </div>
</form>

有什么想法吗?感谢。

1 个答案:

答案 0 :(得分:1)

只需将班级col-lg-6添加到按钮div:

<div class="input-group-btn col-lg-6">
    <button type="submit" class="btn btn-default">Submit</button>    
</div>

&#13;
&#13;
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<form>
   <div class="form-group col-lg-6">
      <label for="email">Nome:</label>
      <input type="email" class="form-control" id="email">
   </div>
   <div class="form-group col-lg-6">
      <label for="pwd">CNPJ:</label>
      <input type="password" class="form-control" id="pwd">
   </div>
   <div class="input-group-btn col-lg-6">
      <button type="submit" class="btn btn-default">Submit</button>    
   </div>
</form>
&#13;
&#13;
&#13;