如何在Sphinx中制作斑马表格?或如何在Sphinx中使用jQuery?

2 投票
1 回答
604 浏览
提问于 2025-04-16 08:52

我觉得Sphinx生成的表格不好看,因为它生成的HTML代码如下。

<table border="1" class="docutils">
<colgroup>
<col width="43%" />
<col width="29%" />
<col width="29%" />
</colgroup>
<thead valign="bottom">
<tr><th class="head">Graph</th>
<th class="head">HIR</th>
<th class="head">AIR</th>
</tr>
</thead>
<tbody valign="top">
<tr><td>Graph</td>
<td>Circuit</td>
<td>System</td>
</tr>
</tbody>
</table>

我该怎么把它变得好看一些,比如变成斑马表格呢?

生成的HTML代码里有jQuery,按照这个网站的说法,只需要一行代码就能做出斑马表格,但我不太确定怎么用jQuery来实现这个斑马表格。

$("tr:nth-child(odd)").addClass("odd");
  • 问:怎么在Sphinx中使用jQuery?
  • 问:有没有其他方法可以在Sphinx中制作斑马表格?

1 个回答

0

我在这里添加了 doctools.js 的以下代码

$(document).ready(function() {
  Documentation.init();
  $('tbody tr:even').css('background-color','#dddddd');
});

撰写回答