如何更改 JupyterLab 中单元格的 style/width?

How to change the style/width of cells in JupyterLab?

我试过了

from IPython.core.display import display, HTML
display(HTML("<style>.container { width:60% !important; }</style>"))

来自这个answer。我也试过了

%%html
<style>.container { width:60% !important; }</style>

但它们不起作用。

classes 的名称在 JupyterLab 中进行了重新设计,现在更易于理解和预测。为 JupyterLab 使用以下选择器:

  • .jp-Cell 改变所有单元格的宽度
  • .jp-Cell.jp-CodeCell 使用代码
  • 仅更改单元格的宽度
  • .jp-Cell.jp-MarkdownCell 更改降价单元格的宽度
  • .jp-Cell.jp-Editor 仅更改编辑器的宽度
  • .jp-OutputArea-output 改变单元输出的with

例如,要使用 IPython 减少单元格的宽度,您可以使用:

from IPython.core.display import display, HTML
display(HTML("<style>.jp-Cell { width: 60% !important; }</style>"))

您可以使用DOM检查器,这是现在所有浏览器都提供的工具,(参见说明here)来检查class 您希望修改的特定元素的名称。