【问题标题】:How to change the style/width of cells in JupyterLab?如何更改 JupyterLab 中单元格的样式/宽度?
【发布时间】:2021-05-22 08:57:29
【问题描述】:

我试过了

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

来自这个answer。我也试过了

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

但它们不起作用。

【问题讨论】:

    标签: html css python-3.x ipython jupyter-lab


    【解决方案1】:

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

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

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

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

    您可以使用 DOM 检查器,这是当今所有浏览器都提供的工具(请参阅说明 here)来检查您希望修改的特定元素的类名。

    【讨论】:

    • 这非常有效,就像一个魅力。在我们调整宽度后,无论如何要使单元格居中吗?
    • 很高兴收到你的问题给我的新question
    • display(HTML("&lt;style&gt;.jp-OutputArea-output { width: 100% !important; margin: 0 auto; }&lt;/style&gt;")) 行在我的 JupyterLab 中不起作用。你能看看我的问题here吗?
    猜你喜欢
    • 2015-11-06
    • 1970-01-01
    • 2021-11-22
    • 2011-02-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-10-06
    • 1970-01-01
    相关资源
    最近更新 更多