【发布时间】:2019-07-08 19:22:36
【问题描述】:
扩展这个优秀的问题:Color coding cells in a table based on the cell value using Jinja templates
我们如何才能将其仅应用于表格的特定列? IE。以第二列为例。
【问题讨论】:
扩展这个优秀的问题:Color coding cells in a table based on the cell value using Jinja templates
我们如何才能将其仅应用于表格的特定列? IE。以第二列为例。
【问题讨论】:
当您迭代一行中的项目(即一行的列)时,您可以使用loop.index0 或loop.index 来设置所需列的样式。
例如,如果您将{% if loop.index == 2 %} <td class="special-colour"> {{ item }} </td>{% endif %} 放在{% for item in row %} 循环中,.special-colour 类将仅适用于第二项。
【讨论】: