【问题标题】:Color coding cells in a table based on the cell value using Jinja2使用 Jinja2 根据单元格值对表格中的单元格进行颜色编码
【发布时间】:2019-07-08 19:22:36
【问题描述】:

扩展这个优秀的问题:Color coding cells in a table based on the cell value using Jinja templates

我们如何才能将其仅应用于表格的特定列? IE。以第二列为例。

【问题讨论】:

    标签: css flask jinja2


    【解决方案1】:

    当您迭代一行中的项目(即一行的列)时,您可以使用loop.index0loop.index 来设置所需列的样式。

    例如,如果您将{% if loop.index == 2 %} <td class="special-colour"> {{ item }} </td>{% endif %} 放在{% for item in row %} 循环中,.special-colour 类将仅适用于第二项。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-09-24
      • 2018-08-15
      • 2022-06-26
      • 2013-06-10
      • 1970-01-01
      • 1970-01-01
      • 2021-03-23
      • 2023-03-14
      相关资源
      最近更新 更多