通过css修改jupyter notebook中代码字体、大小等 您所在的位置:网站首页 anaconda字体放大 通过css修改jupyter notebook中代码字体、大小等

通过css修改jupyter notebook中代码字体、大小等

2024-01-05 16:55| 来源: 网络整理| 查看: 265

jupyter notebook中默认字体不好看且字体过小,因此希望修改字体及大小等。

可以通过修改css文件来完成。

css文件位置:C:\Users\xxxxx\anaconda3\Lib\site-packages\notebook\static\components\codemirror\lib\codemirror.css

打开之后,修改241行.CodeMirror pre.CodeMirror-line-like括号内的参数。

其中font-family为字体,可以添加自己喜欢的字体。(推荐Consolas)

font-size为字体大小。

line-height为一行的高度。(ps:修改完字体要调整一下line-height,否则光标就不能与代码平齐,line-height比font-size稍大即可)

这边主要介绍这三个参数,其余的也可自行调整。

下面贴一段我自己的设置,不想麻烦的朋友可自行将其复制到对应位置覆盖。

.CodeMirror pre.CodeMirror-line-like {   /* Reset some styles that the rest of the page might have set */   -moz-border-radius: 0; -webkit-border-radius: 0; border-radius: 0;   border-width: 0;   background: transparent;   font-family: Consolas, "PingFangSC-Medium", "Microsoft YaHei";   font-size: 18pt;   margin: inherit;   white-space: pre;   word-wrap: normal;   line-height: 22pt;   color: inherit;   z-index: 2;   position: relative;   overflow: visible;   -webkit-tap-highlight-color: transparent;   -webkit-font-variant-ligatures: contextual;   font-variant-ligatures: contextual; }

将css文件保存后重启jupyter notebook即可。

修改行间距,输出、注释字体大小等可参考这位博主的链接。



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有