【问题标题】:Trying to adjust the width for a select option tag using Bootstrap with Rails尝试使用带有 Rails 的 Bootstrap 调整选择选项标签的宽度
【发布时间】:2023-03-24 09:42:02
【问题描述】:

我有以下代码:

%h2=@activity.title
=form_for @time_tracker do |f|
    .text
        =f.label :clock_in
        =f.datetime_select :clock_in
    .text
        =f.label :clock_out
        =f.datetime_select :clock_out
    .btn.btn-primary
        =f.submit "#{text}"

如下图所示,选择范围太广,无法满足我的需求。如何更改 Bootstrap 中选项标签的默认宽度值?

【问题讨论】:

    标签: css ruby-on-rails twitter-bootstrap


    【解决方案1】:

    .css 文件中创建一个类:

    .option-large {
      width: 120px !important;
    }
    

    在您的输入中使用它:

    =f.datetime_select :clock_in, :class => 'option-large'
    

    编辑:

    我认为语法有一个额外的哈希,但我不确定。

    =f.datetime_select :clock_in, {}, {:class => 'option-large'}
    

    【讨论】:

    • 我正在努力解决这个问题。它不想上课。如果需要,它会在选择标签上还是在选项标签上?第一种语法是正确的,但我认为它对于这个选择标签的工作方式不同......
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-06-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-02-24
    • 1970-01-01
    相关资源
    最近更新 更多