如何在Rails表单中保留一个复选框和标签在同一行?(How to keep a checkbox and label on the same line in a Rails form?)

系统教程 行业动态 更新时间:2024-06-14 17:04:03
如何在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

本文发布于:2023-04-24 21:12:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/dzcp/a634215162dfa49984c81a863632f355.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:表单   复选框   标签   如何在   Rails

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!