我在 Sphinx 中有一个简单的
csv-table
指令,我想对其进行样式设置:
Sphinx CSV-Table Styling
------------------------
.. csv-table:: Simple Example
:header: a, b, c, d
:widths: 5, 5, 5, 5
1, 2, 3, 4
5, 6, 7, 8
9, 10, 11, 12
13, 14, 15, 16
我想设计以下样式:
以下是我的解决方案:
.. raw:: html
<style>
table.table1 th {background-color: lightgray}
table.table1 tr:nth-child(even) { background-color: yellow}
table.table1 td:nth-child(3) {background-color: orange}
table.table1 tr:nth-child(1) td:nth-child(2) {background-color: lightblue}
.red {color: red}
</style>
Sphinx CSV-Table Styling
------------------------
.. csv-table:: Simple Example
:header: a, b, c, d
:widths: 5, 5, 5, 5
:class: table1
1, 2, 3, 4
5, 6, 7, 8
:red:`9`, 10, 11, 12
13, 14, 15, 16
一些注意事项:
:class:
指令中设置 csv-table
并创建适当的 CSS 选择器。:red:
) 应用于各个文本位,并在具有相应名称的 CSS 类中设置样式 (.red
)。