Jupyter Lab 中的自定义样式

Custom style in Jupyter Lab

我使用以下行来更改降价单元格的样式

from IPython.core.display import HTML
with open( './custom.css', 'r' ) as f: style = f.read()
HTML( style )

文件 custom.css 包含行

<style>
   div.text_cell_render {font-family: "Times New Roman", Times, serif;}
</style>

这在 jupyter-notebook 中按预期工作(它更改了 markdown 的默认字体)但在 jupyter-lab.

中没有效果

我应该怎么做?

JupyterLab 使用与 jupyter-notebook 不同的 CSS classes 集。

要定位要使用的降价单元格 jp-MarkdownOutput class,例如:

<style>
   div.jp-MarkdownOutput {font-family: "Times New Roman", Times, serif;}
</style>

您可以在 the documentation 的 JupyterLab 中阅读有关 CSS 的更多信息。