首页 > 解决方案 > 引导表 - 行样式不适用于整行?

问题描述

我正在使用引导表并使用haml动态制作表。我面临的问题是,对于每个medication,它可以有不同数量的dosages. 因此,当生成表格时,它的外观并不统一。列数较少的行样式不会覆盖整行。背后的原因是<td>DOM 中不存在 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

标签: cssruby-on-railstwitter-bootstrap-3

解决方案


目前,我想出了一个在未占用的行空间中创建空列的解决方案。我计算了最大行大小并生成了 (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

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


推荐阅读