【发布时间】:2019-03-10 01:11:53
【问题描述】:
我正在使用 Simple_form 和 Bootstrap。
我想使用水平包装,但我需要使标签更宽,输入更窄。我想用 bootstrap 4 vs custom css 来做到这一点。
标签和输入应该在同一行(内联),并且右对齐。
col-md-8 用于标签,col-md-4 用于输入。我该怎么做?
<%= f.input :role, :wrapper =>:horizontal_range, input_wrapper_html: { class: "col-md-4"}, label_wrapper_html: {class: "col-md-8"} %>
编辑:我应该补充一点,f.input :role 包含在
中<div class='row'>
<div class='col-md-6">
f.input :role
</div>
</div>
第二,
我需要在输入的末尾添加一个 %。但是,它似乎不起作用。
<%= f.input :pct_of_car , append: "%", :wrapper =>:horizontal_range %>
但是,这似乎不起作用。我的语法有什么问题?
第三,如何将垂直collection_inline 修改为2 或3 列?
# vertical input for inline radio buttons and check boxes
config.wrappers :bs_vertical_collection_inline, item_wrapper_class: 'form-check form-check-inline', tag: 'fieldset', class: 'form-group', error_class: 'form-group-invalid', valid_class: 'form-group-valid' do |b|
b.use :html5
b.optional :readonly
b.wrapper :legend_tag, tag: 'legend', class: 'col-form-label pt-0' do |ba|
ba.use :label_text
end
b.use :input, class: 'form-check-input', error_class: 'is-invalid', valid_class: 'is-valid'
b.use :full_error, wrap_with: { tag: 'div', class: 'invalid-feedback d-block' }
b.use :hint, wrap_with: { tag: 'small', class: 'form-text text-muted' }
end
目前所有的复选框都是内联列出的,没有结构。我需要在 2 或 3 列中列出选项,以便于阅读。这也是一个很长的列表,因此可能需要将选项包装在滚动框中。
【问题讨论】:
标签: ruby-on-rails twitter-bootstrap simple-form ruby-on-rails-5.2