2013-04-17 58 views
13

Tôi đã gặp vấn đề sau với trường văn bản kiểu khởi động và nút nhập nhiều lần. Chú ý rằng họ không theo chiều dọc thẳng hàng:Căn chỉnh hộp văn bản và nút, bootstrap

enter image description here

Làm thế nào để sắp xếp hai yếu tố này? Dưới đây là HTML:

<div class="span6"> 
    <input type="text" placeholder="email"> <button type="button" class="btn btn-info">Sign up</button> 
</div> 
+0

thể trùng lặp của [bootstrap: sắp xếp đầu vào với nút] (http://stackoverflow.com/questions/10615872/bootstrap-align-input-with-button) –

Trả lời

27

Để hoàn tất, bạn phải sử dụng đúng Twitter Bootstrap classes for forms.

Trong trường hợp này, đó là .form-inline lớp.

Dưới đây là đánh dấu thích hợp:

<form class="form-inline"> 
    <input type="text" class="input-small" placeholder="Email"/> 
    <button type="submit" class="btn">Sign in</button> 
</form> 

Dưới đây là bản demo http://jsfiddle.net/YpXvT/42/

+0

Điều đó đã làm được! Sẽ chấp nhận trong 4 phút :) – jn29098

+0

Chào mừng bạn :) –

3
<div class="navbar-form pull-left"> 
    <input type="text" class="span2"> 
    <button class="btn">Sign up</button> 
</div> 

sao chép từ http://twitter.github.io/bootstrap/components.html#navbar

hoặc

<div class="input-append"> 
    <input type="text"/> 
    <button class="btn">Sign up</button> 
</div> 

hoặc

<div class="form-horizontal"> 
    <input type="text"/> 
    <button class="btn">Sign up</button> 
</div> 
0
<div class="input-group"> 
     <input type="email" class="form-control" required="required" placeholder="[email protected]"> 
     <span class="input-group-btn"> 
      <button class="btn btn-default" type="submit"><i class="fa fa-send"></i></button> 
     </span> 
    </div> 

thay đổi css cho lớp đầu vào-group-BTN trong boostrap-min: vertical-align => top nó s công việc cho tôi

Các vấn đề liên quan