gpt4 book ai didi

ruby-on-rails - 将复选框和标签与 collection_check_box 对齐

转载 作者:行者123 更新时间:2023-12-04 06:19:17 24 4
gpt4 key购买 nike

我和这里的海报有同样的问题Align checkboxes for f.collection_check_boxes with Simple_Form

我的复选框代码是:

<%= f.collection_check_boxes :investor_city_ids, r.cities, :id, :name, {:item_wrapper_class => 'checkbox_container'} %>

但是我在生成的 HTML 中看到没有为生成的 HTML 设置类

<input id="investor_investor_city_ids_1" name="investor[investor_city_ids][]" type="checkbox" value="1">
<label for="investor_investor_city_ids_1">Hamilton</label>
<input id="investor_investor_city_ids_2" name="investor[investor_city_ids][]" type="checkbox" value="2">
<label for="investor_investor_city_ids_2">Cambridge</label>

我也尝试过不带 {} 大括号的 collection_check_boxes 代码,但似乎没有任何效果。

CSS 是

.checkbox_container {
display: inline-block;
vertical-align: -1px;
margin: 5px;
}
.checkbox_container input {
display: inline;
}
.checkbox_container .collection_check_boxes{
display: inline;
vertical-align: -5px;
}

最佳答案

已修复 - 我正在使用 form_for,更改为 simple_form_for 解决了这个问题。不确定为什么它不适用于 form_for。

关于ruby-on-rails - 将复选框和标签与 collection_check_box 对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20926661/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com