![](/img/trans.png)
[英]How do I style the 'label' of each checkbox generated by Simple_Form?
[英]How to add a label on the checkbox simple_form and style the label inline to the checkbox?
我有一個沒有標簽的復選框。 我如何在simple_form中添加標簽標記,在復選框的HTML標簽標記中插入復選框。
我目前有復選框和純文本。
<%= f.check_box :is_positive, as: :boolean, checked_value: true, unchecked_value: false %> Is positive?
我嘗試了下面的代碼,但是它使標簽高於實際的復選框。
<%= f.input :is_positive, as: :boolean, checked_value: true, unchecked_value: false, inline_label: 'Is positive?' %>
有沒有辦法標記復選框並使其標簽內聯到復選框?
請嘗試下面的代碼,您可以使用css
將標簽的樣式更改為所需的樣式:
<%= f.label :is_positive do %>
<%= f.check_box :is_positive, as: :boolean, checked_value: true, unchecked_value: false %> <span class="labelText">Is positive?</span>
<% end %>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.