jupyter-notebook - 单元格的 ipython 笔记本背景颜色

标签 jupyter-notebook background-color

如何更改 iPython Notebook 中特定单元格的背景颜色?例如,我正在写一本手册,我想在灰色文本框中添加一些终端命令,如 http://ipython.org/ipython-doc/1/interactive/nbconvert.html .

最佳答案

基本上,您可以在 markdown 单元格中以预先格式化的代码块编写终端命令。
对于单行(内联)代码,您可以使用双坟(``),如echo 1 (“回声 1”)。这与 Stackoverflow 上的完全一样。

较长的代码片段(带有语法突出显示)可能更好地放置在 protected 代码块中,例如

```重击
对于 *.jpg 中的 i;做
显示 $i
完毕
```
在这里,bash 指定了语法颜色。这在 IPython 2.x 中呈现
enter image description here
如果您想要不同的背景样式,可以使用 CSS 样式。例如。在代码单元格中添加以下行,或者更好(稍微适应)到您的 custom.css。

%%html
<style type="text/css">
.rendered_html code  {
   background-color:#E8E8E8;
   padding: 3px;
};
</style>

有了这个,预格式化的代码看起来像
enter image description here

关于jupyter-notebook - 单元格的 ipython 笔记本背景颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28034783/

相关文章:

html - 未知背景颜色的 CSS 继承实际上是透明的

python - 以编程方式获取当前的 IPython 笔记本单元格输出?

jupyter-notebook - 从 ipython 笔记本运行 scp

ipython - 防止用户在 ipython-notebook 环境中删除文件

python - pygal 图表不在 Jupyter/IPython 笔记本中显示工具提示

javascript - 颜色选择器没有响应

JavaFX CSS : How to inherit background color from other CSS settings?

css - 应用于背景图像的背景颜色色调效果

twitter-bootstrap - 在 Twitter 的 Bootstrap 2.3.2 中更改导航栏颜色

python - 在 Windows 上通过命令行运行 Jupyter