css - Set form fields side-by-side using bootstrap in rails -
i have rails application want form-fields side-by-side , not below. best can them side-by-side using form-inline label gets aligned left. labels should in top. want know how keep size of form fields half. code is:
<div class="container"> <%= form_for '#' |f|%> <div class= "hero-unit"> <%=f.label "first name"%> <%=f.text_field '#', :class=>"span5" %> <%=f.label "last name" %> <%=f.text_field '#', :class=>"span5" %> </div> <% end %> </div>
and results in: require is:
please help.
you need use bootstrap grid system in order achieve want. bootstrap has grid divided in 12 columns. inputs can, in same row, nested, stacked, offsetted, etc. use "row" class create horizontal columns, , predefined grid classes columns on span content.
in case, you'll need row 2 grid columns, such:
<div class="container"> <%= form_for '#' |f|%> <div class="hero-unit"> <div class="row"> <div class="col-md6"> <%=f.label "first name"%> <%=f.text_field '#' %> </div> <div class="col-md6"> <%=f.label "last name" %> <%=f.text_field '#' %> </div> </div> </div> <% end %> </div>
Comments
Post a Comment