2

我在重组文本中定义了下表:

+-------------------------+--------------------+
| Label                   |Description         |
+=========================+====================+
| foo                     |Two options:        |
|                         |                    |
|                         |* Thing 1           |
|                         |* Thing 2           |
+-------------------------+--------------------+
| bar                     |Bar does something. |
+-------------------------+--------------------+

当它在 html 中呈现时(使用Sphinx),“两个选项: ”文本被包裹在一个段落标签中。“ Bar 做了一些事情。 ”文本不会使用段落标签呈现。应用样式表时,这会导致单元格文本看起来不同:

在此处输入图像描述

有没有办法对这两种情况强制执行相同的行为?

4

1 回答 1

1

Sphinx 更改 CSS 声明的方法:在 conf.py 中添加一行

templates_path = ['my_template_path']

并在my_template_path中添加一个文件 layout.html。在那里,您可以覆盖定义表格内容布局的主题的 css 类。类名取决于您的主题。尝试使用浏览器的开发人员功能找出它。在我的主题中,第一段的定义是class="first"。在这里我用

td > p.first { margin: 0; }

列表 ul 有class="last simple",被覆盖

td > ul.last.simple { margin: 0; }

layout.html应具有以下形式

{% extends "!layout.html" %}
<style type="text/css">

/* Add class definitions here */

</style>

希望有帮助。此处此 stackoverflow-thread中的更多解释。

于 2016-09-08T11:11:46.277 回答