daveydave400给出了基本答案,但我想添加分步说明:
1) 制作您的自定义样式表,例如 custom.css
@import url("default.css");
div.admonition-todo {
border-top: 2px solid red;
border-bottom: 2px solid red;
border-left: 2px solid red;
border-right: 2px solid red;
background-color: #ff6347
}
2) 将其复制到 sphinx 文档的 source/_static 目录(在您的情况下可能是 .static,请查看 conf.py 中的 html_static_path)
3) 编辑 sphinx 文档的 conf.py;在那里添加
html_style = 'custom.css'
它对我有用!
如果您想在许多项目中使用彩色待办事项框,请考虑编写自己的主题:
1) 在Lib\site-packages\sphinx\themes中创建目录custom
2) 在那里创建包含theme.conf 的文件
[theme]
inherit = default
stylesheet = custom.css
3)创建custom\static子目录,把上面提到的custom.css文件,重命名为custom.css_t
4) 在conf.py 中生成html_theme = 'custom'
事实上,您可以为任何通用警告着色。例如,你在文本中有:
.. admonition:: Information
some info
(“一些信息”之前的空行是必不可少的)
您可以添加到custom.css(或custom.css_t,如果您制作自己的主题):
div.admonition-information {
border-top: 2px solid green;
border-bottom: 2px solid green;
border-left: 2px solid green;
border-right: 2px solid green;
background-color: #63cc47
}
颜色信息警告