css - 引导表 - 行样式不适用于整行?
问题描述
我正在使用引导表并使用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
解决方案
目前,我想出了一个在未占用的行空间中创建空列的解决方案。我计算了最大行大小并生成了 (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
有没有其他/更好的方法来解决这个问题?
推荐阅读
- google-apps-script - 使用 FormResponse.getEditResponseUrl 时无法编辑响应错误
- system-verilog - 将模块作为类型传递
- python - 计算具有特定值的元素在不同列中的出现次数
- google-sheets - 如何从 ImportXML 函数永久更新值
- javascript - 来自匿名函数的错误:意外令牌 <
- django - Django:如何有条件地过滤外键
- c# - 生成立方体球体
- python - 值为 2 的 int() 的 ValueError 无效文字:Python 中的 ''
- excel - VBA Excel 打印 Word Doc - 不打印
- android - 如果android studio自动更改代码如何解决?