作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我和这里的海报有同样的问题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/
我是一名优秀的程序员,十分优秀!