Jupyter Lab 中的自定义样式

Pri*_*tri 5 css python jupyter-notebook jupyter-lab

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

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

该文件custom.css包含行

<style>
   div.text_cell_render {font-family: "Times New Roman", Times, serif;}
</style>
Run Code Online (Sandbox Code Playgroud)

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

我该怎么做?

kra*_*ski 3

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

要定位 Markdown 单元格,您需要使用jp-MarkdownOutput类,例如:

<style>
   div.jp-MarkdownOutput {font-family: "Times New Roman", Times, serif;}
</style>
Run Code Online (Sandbox Code Playgroud)

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