You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Google Colab中切换为类似Jupyter Notebook的深色主题?

在Google Colab中切换深色主题及自定义为Jupyter Notebook风格深色主题

一、快速切换Colab官方深色主题

这是最省心的方法,几步就能搞定:

  • 打开Google Colab后,点击右上角的齿轮图标(设置按钮)
  • 在弹出的设置面板中,切换到Site标签页
  • 找到Theme下拉选项,直接选择Dark,页面会立刻切换到官方深色主题

二、自定义为类似Jupyter Notebook的深色主题

如果Colab官方的深色主题不符合你的习惯,想要贴近Jupyter经典深色风格,可以通过自定义CSS实现:

  1. 在你的Colab笔记本里新建一个代码单元格
  2. 粘贴以下代码到单元格中:
from IPython.display import HTML
HTML("""
<style>
/* 核心背景与文字配色匹配Jupyter Dark */
body {
  background-color: #1e1e1e !important;
  color: #d4d4d4 !important;
}
/* 代码编辑器区域样式 */
.CodeMirror {
  background-color: #1e1e1e !important;
  color: #d4d4d4 !important;
}
/* 代码高亮配色对齐Jupyter标准 */
.cm-keyword { color: #569cd6 !important; }
.cm-comment { color: #6a9955 !important; }
.cm-string { color: #ce9178 !important; }
.cm-number { color: #b5cea8 !important; }
.cm-variable { color: #9cdcfe !important; }
/* 工具栏与面板样式调整 */
#colab-toolbar {
  background-color: #2d2d2d !important;
}
.notebook-container {
  background-color: #1e1e1e !important;
}
/* 代码输出区域样式统一 */
.output_area pre {
  background-color: #1e1e1e !important;
  color: #d4d4d4 !important;
}
</style>
""")
  1. 运行这个单元格,页面会自动应用Jupyter风格的深色样式

小提示:这种自定义样式只在当前会话生效,下次打开笔记本需要重新运行该单元格。如果想进一步调整细节,可以修改CSS里的颜色值,完全适配你的喜好。

内容的提问来源于stack exchange,提问作者Karthick Aravindan

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 06:35:05