Typora更改代码块颜色

Typora中,找到主题文件夹:文件 -> 偏好设置 -> 外观 ->打开主题文件夹。
主题文件夹下创建base.user.css文件,内容如下:
 
.CodeMirror-line .cm-number{color:#7f6bff} /*数字,蓝色*/
.CodeMirror-line .cm-property {
    color: #f08d49;
}
.CodeMirror-line .cm-variable-3{color:#ffed6b} /*返回值、变量类型,int、void等,淡黄色*/
.CodeMirror-line .cm-qualifier{color:#888}
.CodeMirror-line .cm-variable-2 {
    color: #888;
} 
.CodeMirror-line .cm-meta{ color:#BBFFFF}  /* 头文件、宏定义一整行 青色*/
.CodeMirror-line .cm-atom { color:#f9ff00} /* true、false 黄色*/
.CodeMirror-line .cm-keyword{    color: #ff1800;} /* if、return等关键字红色*/

.CodeMirror-line .cm-def{ color:#00ff00  } /* 函数定义,绿色 */


.CodeMirror-line .cm-variable { color: #90EE90; } /* 入参定义,亮绿色 */

.CodeMirror-line .cm-builtin {
    color: #82AAFF;
}/* 蓝色 */
.CodeMirror-line .cm-comment {
    color: #888;
} /* 灰色 */
.CodeMirror-line .cm-string{ color: #82AAFF  } /* 字符串, 蓝色*/
.CodeMirror-line .cm-string-2 { color: #888  }
.CodeMirror-line .cm-operator {color: #ff1800}/* +=等操作符,红色*/
.CodeMirror div.CodeMirror-cursor {
    border-left: 1px solid #fff;
    z-index: 3;
}
.CodeMirror-selected,
.CodeMirror-selectedtext {
    background: #666 !important;
}
 
 
.CodeMirror-line .cm-tag{
    color: #F07178;
}
.CodeMirror-line .cm-bracket{
    color: #FFF;
}
.CodeMirror-line .cm-attribute{
    color: #FFCB6B;
}

.sidebar-content {
    counter-reset: h1
}
 
.outline-h1 {
    counter-reset: h2
}
 
.outline-h2 {
    counter-reset: h3
}
 
.outline-h3 {
    counter-reset: h4
}
 
.outline-h4 {
    counter-reset: h5
}
 
.outline-h5 {
    counter-reset: h6
}
 
.outline-h1>.outline-item>.outline-label:before {
    counter-increment: h1;
    content: counter(h1) " "
}
 
.outline-h2>.outline-item>.outline-label:before {
    counter-increment: h2;
    content: counter(h1) "."counter(h2) " "
}
 
.outline-h3>.outline-item>.outline-label:before {
    counter-increment: h3;
    content: counter(h1) "."counter(h2) "."counter(h3) " "
}
 
.outline-h4>.outline-item>.outline-label:before {
    counter-increment: h4;
    content: counter(h1) "."counter(h2) "."counter(h3) "."counter(h4) " "
}
 
.outline-h5>.outline-item>.outline-label:before {
    counter-increment: h5;
    content: counter(h1) "."counter(h2) "."counter(h3) "."counter(h4) "."counter(h5) " "
}
 
.outline-h6>.outline-item>.outline-label:before {
    counter-increment: h6;
    content: counter(h1) "."counter(h2) "."counter(h3) "."counter(h4) "."counter(h5) "."counter(h6) " "
}
 
#write {
    counter-reset: h1
}
 
h1 {
    counter-reset: h2
}
 
h2 {
    counter-reset: h3
}
 
h3 {
    counter-reset: h4
}
 
h4 {
    counter-reset: h5
}
 
h5 {
    counter-reset: h6
}
 
#write h1:before {
    counter-increment: h1;
    content: counter(h1) " "
}
 
#write h2:before {
    counter-increment: h2;
    content: counter(h1) "."counter(h2) " "
}
 
#write h3:before,
h3.md-focus.md-heading:before
 
    {
    counter-increment: h3;
    content: counter(h1) "."counter(h2) "."counter(h3) " "
}
 
#write h4:before,
h4.md-focus.md-heading:before {
    counter-increment: h4;
    content: counter(h1) "."counter(h2) "."counter(h3) "."counter(h4) " "
}
 
#write h5:before,
h5.md-focus.md-heading:before {
    counter-increment: h5;
    content: counter(h1) "."counter(h2) "."counter(h3) "."counter(h4) "."counter(h5) " "
}
 
#write h6:before,
h6.md-focus.md-heading:before {
    counter-increment: h6;
    content: counter(h1) "."counter(h2) "."counter(h3) "."counter(h4) "."counter(h5) "."counter(h6) " "
}
 
#write>h3.md-focus:before,
#write>h4.md-focus:before,
#write>h5.md-focus:before,
#write>h6.md-focus:before,
h3.md-focus:before,
h4.md-focus:before,
h5.md-focus:before,
h6.md-focus:before {
    color: inherit;
    border: inherit;
    border-radius: inherit;
    position: inherit;
    left: initial;
    float: none;
    top: initial;
    font-size: inherit;
    padding-left: inherit;
    padding-right: inherit;
    vertical-align: inherit;
    font-weight: inherit;
    line-height: inherit;
}
 
.CodeMirror-lines {
    padding-left: 4px;
}
 
.code-tooltip {
    box-shadow: 0 1px 1px 0 rgba(0,28,36,.3);
    border-top: 1px solid #eef2f2;
}
 
.md-fences,
code,
tt {
    background-color: #f8f8f8;
    border-radius: 3px;
    padding: 0;
    padding-left: 4px !important;
    padding-right: 4px !important;
    font-size: 0.9em;
}
 
code {
    background-color: #f3f4f4;
    padding: 0 2px 0 2px;
}
 
.md-fences {
    margin-bottom: 15px;
    margin-top: 15px;
    padding-top: 8px;
    padding-bottom: 6px;
}
 
 
.md-task-list-item > input {
  margin-left: -1.3em;
}
 
@media print {
    html {
 font-size: 13px;
    }
    table,
    pre {
 page-break-inside: avoid;
    }
    pre {
 word-wrap: break-word;
    }
}
 
.md-fences {
    background-color: #f8f8f8;
}
#write pre.md-meta-block {
    padding: 1rem;
    font-size: 85%;
    line-height: 1.45;
    background-color: #f7f7f7;
    border: 0;
    border-radius: 3px;
    color: #777777;
    margin-top: 0 !important;
}
 
.mathjax-block>.code-tooltip {
    bottom: .375rem;
}
 
 
 
 
 
#write .md-fences:not([mermaid-type])  {
    padding-top: 7px;
    border-radius: 10px;
    background-color: #282c34;
    color: #eeeeee;
}
 
.code-tooltip .ty-input,
.code-tooltip input {
    color: #eee;
}
 
 
 
.CodeMirror-wrap .CodeMirror-scroll {
    padding-top: 20px;
}
 
#write .md-fences:before {
    content: "";
    z-index: 4;
    display: block;
    position: absolute;
    top: 7px;
    left: 13px;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    float: left;
    background-color: #fa3534;
}
 
#write .CodeMirror-scroll:before {
    content: "";
    display: block;
    position: absolute;
    top: 0px;
    left: 29px;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    float: left;
    z-index: 999;
    background-color: #ff9900;
}
#write .md-fences::after {
    content: "";
    z-index: 4;
    display: block;
    position: absolute;
    top: 7px;
    left: 53px;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    float: left;
    background-color: #19be6b;
}

参考:
https://www.typora.net/490.html
https://huaweicloud.csdn.net/638ef02ddacf622b8df8dd8d.html

  • 7
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 3
    评论
Typora中设置代码块颜色可以通过修样式文件来实现。首先,你需要找到Typora的安装目录,默认为C:\Program Files\Typora\resources\app\style\。在该目录下找到base-control.css文件。打开该文件后,搜索.CodeMirror-lines,找到max-width属性,将其值为1200。这将设置编辑器的宽度。\[2\] 接下来,你需要打开github.css文件。在该文件中,你可以找到.md-fences、code和.md-fences等样式。你可以根据需要修这些样式来代码块颜色。例如,你可以修code样式的background-color属性来代码块的背景色,修color属性来变字体颜色。\[3\] 请注意,修样式文件可能会影响到其他部分的样式,所以在修之前最好备份一下原始文件。另外,修样式文件后,你可能需要重新启动Typora才能看到修后的效果。 #### 引用[.reference_title] - *1* *2* [Typora 更改编辑器、源代码模式的宽度、块代码的颜色](https://blog.csdn.net/xiaojin21cen/article/details/90292315)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] - *3* [Typora块代码的颜色](https://blog.csdn.net/weixin_44560698/article/details/120309042)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

HHT0506

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值