Css 使用simple_form如何在这些内部标签和外部标签上获得此类?
这就是我想要得到的结果:Css 使用simple_form如何在这些内部标签和外部标签上获得此类?,css,ruby-on-rails,ruby-on-rails-3,simple-form,Css,Ruby On Rails,Ruby On Rails 3,Simple Form,这就是我想要得到的结果: <div class="control-group"> <label class="control-label" for="ListingType">Listing Type:</label> <div class="controls"> <label class="inline"><input type="radio" name="ListingType"> For Sale<
<div class="control-group">
<label class="control-label" for="ListingType">Listing Type:</label>
<div class="controls">
<label class="inline"><input type="radio" name="ListingType"> For Sale</label>
<label class="inline"><input type="radio" name="ListingType"> For Rent</label>
</div>
</div>
i、 e.它将类内联
移动到最外面的
,而不是每个单选按钮的标签
想法?只是将@flynfish答案从复制到此线程。根据@marcamillion的评论,似乎就是这个 您可以使用以下选项为标签指定一个类:item\u wrapper\u class=> “这里上课” 以下是一个完整的示例:
= user.input :resident,
:collection => [["In the U.S", true],["Outside the U.S.", false]],
:label_method => :first,
:value_method => :last,
:as => :radio_buttons,
:label => "Where is your principle residence?",
:item_wrapper_class => 'inline'
@moonfly给出的答案在当前版本的
simple\u form
中不再适用(我已经在版本3.3.1上试用过)
要更改每个单选按钮标签的类别,必须使用选项item\u label\u class
,如下所示:
<%= f.association :listing_type, label: "Listing Type: ", as: :radio_buttons, item_label_class: 'inline' %>
item\u wrapper\u class
将修改每个单选按钮跨距的类,以获得较新版本的simple\u表单。选中此项,因此线程:完美…您想在此处添加投票最多的答案,即有6票以上的答案…我将接受它。刚试过,效果不错。谢谢这在最新版本中不再有效,该类将应用于标签类周围的范围:(-不知道他们为什么更改此选项:(
<div class="control-group radio_buttons optional">
<label class="radio_buttons optional control-label inline">Listing Type:</label>
<div class="controls">
<label class="radio"><input class="radio_buttons optional" id="listing_listing_type_id_1" name="listing[listing_type_id]" type="radio" value="1" />For Sale</label>
<label class="radio"><input class="radio_buttons optional" id="listing_listing_type_id_2" name="listing[listing_type_id]" type="radio" value="2" />For Rent</label>
</div>
</div>
= user.input :resident,
:collection => [["In the U.S", true],["Outside the U.S.", false]],
:label_method => :first,
:value_method => :last,
:as => :radio_buttons,
:label => "Where is your principle residence?",
:item_wrapper_class => 'inline'
<%= f.association :listing_type, label: "Listing Type: ", as: :radio_buttons, item_label_class: 'inline' %>
= user.input :resident,
:collection => [["In the U.S", true],["Outside the U.S.", false]],
:label_method => :first,
:value_method => :last,
:as => :radio_buttons,
:label => "Where is your principle residence?",
:item_label_class => 'inline'