【问题标题】:Rails + Simple_form_for: How to separated output of "f.association" in two columns?Rails + Simple_form_for:如何在两列中分离“f.association”的输出?
【发布时间】:2014-09-25 12:17:24
【问题描述】:

我有一个这样使用的关联:

<%= f.association :cars, as: :check_boxes, 
                         label_method: :label, 
                         value_method: :id,
                         label: 'Cars' %>

它运作良好,但从美学角度来看,它看起来并不好。我想将复选框排列成两列。

怎么做?

谢谢

【问题讨论】:

  • arrange checkboxes into two columns 是什么意思?

标签: ruby-on-rails ruby checkbox associations simple-form


【解决方案1】:

我认为处理此问题的最佳方法可能只是添加一个 item-wrapper 类,然后根据需要设置复选框容器的样式。也许有一个固定的宽度和一个浮动。

<%= f.association :cars, as: :check_boxes, 
                     label_method: :label, 
                     value_method: :id,
                     label: 'Cars',
                     item_wrapper_class: 'car-checkbox-container' %>

然后在你的样式表中...

.car-checkbox-container {
  width: 200px;
  float: left;
}

【讨论】:

    猜你喜欢
    • 2017-09-17
    • 1970-01-01
    • 2015-01-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-01-29
    • 2014-06-06
    相关资源
    最近更新 更多