【问题标题】:Bootstrap table - row styling not applying on whole row?引导表 - 行样式不适用于整行?
【发布时间】:2019-03-21 16:10:38
【问题描述】:

我正在使用引导表并使用 haml 动态创建表。我面临的问题是,对于每个medication,它可以有不同数量的dosages。因此,在生成表格时,它的外观并不统一。列数较少的行样式不会覆盖整行。背后的原因是 DOM 中不存在 <td> html 代码。我正在寻找一个引导元素或类,它可以根据最大行动态分析行的大小并相应地应用引导样式。

.table-responsive.table-bordered
  %table.table.table-striped
    %thead
      %tr
        %th Drug
        %th Dosage
    %tbody
      - user.medications.each do |med|
        %tr
          %th
            = med.drug.name
          -med.dosages.each do |dose|
            %td
              = dose.dosage_time

【问题讨论】:

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


    【解决方案1】:

    目前,我想出了一个在未占用的行空间中创建空列的解决方案。我计算了最大行大小并生成了 (max - current_size) 列数。因此,该行应始终具有最大尺寸和样式等适用于整行表格。

    -max_count = max_dosage(user)
    .table-responsive.table-bordered
      %table.table.table-striped
        %thead
          %tr
            %th Drug
            %th Dosage
        %tbody
          - user.medications.each do |med|
            %tr
              %th
                = med.drug.name
              -dosage_count = med.dosages.size
              -med.dosages.each do |dose|
                %td
                  = dose.dosage_time
                -(max_count - dosage_count).times do 
                  %td
    

    有没有其他/更好的方法来解决这个问题?

    【讨论】:

      猜你喜欢
      • 2017-04-15
      • 1970-01-01
      • 1970-01-01
      • 2021-03-27
      • 2014-05-02
      • 2014-10-28
      • 2016-07-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多