如何在Rails表单中保留一个复选框和标签在同一行?(How to keep a checkbox and label on the same line in a Rails form?)
使用包含表单的rails视图中的复选框,将复选框的标签保持在同一行上应该怎么办?
标签目前在下一行:
<div class="span6 offset3"> <%= form_for(@user) do |f| %> <%= render 'shared/error_messages', object: f.object %> <%= f.label :name %> <%= f.text_field :name %> <br> <%= f.check_box :terms_of_service %> <%= f.label :terms_of_service, "I agree to the #{link_to 'Terms of Service', policies_path}.".html_safe %> <br><br> <%= f.submit "Create my account", :class => "btn btn-large btn-primary" %> <% end %>谢谢亚历山德拉
What should I do to keep the label of a checkbox on the same line with the checkbox in a rails view containing a form?
Currently the label goes on the next line:
<div class="span6 offset3"> <%= form_for(@user) do |f| %> <%= render 'shared/error_messages', object: f.object %> <%= f.label :name %> <%= f.text_field :name %> <br> <%= f.check_box :terms_of_service %> <%= f.label :terms_of_service, "I agree to the #{link_to 'Terms of Service', policies_path}.".html_safe %> <br><br> <%= f.submit "Create my account", :class => "btn btn-large btn-primary" %> <% end %>Thank you, Alexandra
最满意答案
看起来你正在使用Bootstrap,所以我建议您调整视图代码以使用Bootstrap文档本节中描述的水平表单布局: http : //getbootstrap.com/css/#forms
It looks like you're using Bootstrap, so I recommend adapting your view code to use the horizontal form layout described in this section of the Bootstrap docs: http://getbootstrap.com/css/#forms
更多推荐
<%,%>,label,class,电脑培训,计算机培训,IT培训"/> <meta name="descr
发布评论