水平形式的复选框以及标签的右侧
问题描述:
是否有可能像其他复选框标签一样左侧复选框,右侧的复选框与其他横向形式的输入一样?水平形式的复选框以及标签的右侧
我的当前设置
它看起来很可怕。
编辑:
<%= simple_form_for :apartment, :html => {:multipart => true, :class => 'form-horizontal'}, wrapper: :horizontal_form do |f| %>
<%= f.input :pets, as: :boolean, label: 'Husdyr tilladt' %>
<% end %>
生成视图下面的HTML:
<div class="form-group boolean optional apartment_pets">
<div class="checkbox"><input value="0" type="hidden" name="apartment[pets]">
<label class="boolean optional" for="apartment_pets"><input class="boolean optional" type="checkbox" value="1" name="apartment[pets]" id="apartment_pets">
Husdyr tilladt
</label>
</div>
</div>
答
您可以添加pull-right
到班级的复选框元素,像这样:
<input name="uh" id="uhhuh" type="checkbox" class="pull-right" />
已更新ans WER利用用户提供的代码:
<div class="form-group boolean optional apartment_pets">
<div class="checkbox"><input value="0" type="hidden" name="apartment[pets]">
<label class="boolean optional" for="apartment_pets">Husdyr tilladt</label>
<input class="boolean optional" type="checkbox" value="1" name="apartment[pets]" id="apartment_pets" class="pull-right">
</div>
</div>
我从来没有使用过simple_form
但是从浏览文档,它看起来像你应该使用的:label => false
和:inline_label => true
组合定位标签。
你可能会添加一些代码吗?同样,你是否使用Bootstrap作为你的CSS框架? –
@ Christian-G我已经用代码更新了这个问题。不幸的是,你以前的建议没有任何区别。 – FrankfromDenmark
用你的代码更新了我的答案 –