Typora配色和标题自带序号

(老是有人盗用我的文章还不给我打链接。。。气气。。。原文链接 https://blog.csdn.net/qq_43778239/article/details/109810113)

效果展示

使用前效果

在这里插入图片描述

使用后效果

在这里插入图片描述
在这里插入图片描述

代码添加位置和添加方法

先打开主题文件夹

文件>偏好设置>外观>打开主题文件夹

然后编辑base.user.css(如果没有就新建一个)文件

将喜欢的效果部分对应的代码加入即可(自选效果),也可以直接使用后面的汇总代码(所有效果)

代码及其效果

标题自带行号

前后效果对比


在这里插入图片描述


在这里插入图片描述


代码

/*标题自动添加序号*/
.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;
}

代码块仿MAC图标

前后效果对比


在这里插入图片描述


在这里插入图片描述


/*因为不同主题的代码块部分不一样,code部分统一*/
.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;
}

/*MAC的三个图标*/

#write .md-fences:not([mermaid-type]):before {
    content: "";
    z-index: 4;
    display: block;
    position: absolute;
    top: 7px;
    left: 13px;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    float: left;
    background-color: #fa3534;
}

.md-fences:not([mermaid-type]) .cm-s-inner{
    padding-top: 30px;
}

.md-fences:not([mermaid-type]) .cm-s-inner:before {
    content: "";
    display: block;
    position: absolute;
    top: 0px;
    left: 29px;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    float: left;
    z-index: 4;
    background-color: #ff9900;
}
#write .md-fences:not([mermaid-type])::after {
    content: "";
    z-index: 4;
    display: block;
    position: absolute;
    top: 7px;
    left: 53px;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    float: left;
    background-color: #19be6b;
}

代码块配色

效果对比


在这里插入图片描述


在这里插入图片描述


/*深色背景*/

#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;
}

/*高亮配色*/
.cm-s-inner .cm-number,/*数字*/
.cm-s-inner .cm-property {/*被调用的方法*/
    color: #f08d49 !important;
}
.cm-s-inner .cm-variable-3,/*形参,类型*/
.cm-s-inner .cm-qualifier,/*css class*/
.cm-s-inner .cm-variable-2 {/*被使用的形参*/
    color: #FFCB6B;
}
.cm-s-inner .cm-meta,/*省略号,注解等*/
.cm-s-inner .cm-atom,/*css属性值,布尔值等等*/
.cm-s-inner .cm-keyword{/*关键字*/
    color: #cc99cd;
}
.cm-s-inner .cm-def,/*变量名*/
.cm-s-inner .cm-variable {/*被使用的变量名*/
    color: #FFCB6B;
}
.cm-s-inner .cm-builtin {/*被调用的属性,php中是被调用的函数*/
    color: #82AAFF;
}
.cm-s-inner .cm-comment {/*注释*/
    color: #888;
}
.cm-s-inner .cm-string,/*字符串*/
.cm-s-inner .cm-type,/*类型*/
.cm-s-inner .cm-string-2 {/*正则表达式*/
    color: #7ec699
}
.CodeMirror-line .cm-operator {/*运算符*/
    color: #67cdcc
}
.CodeMirror div.CodeMirror-cursor {/*光标*/
    border-left: 1px solid #EEE;
    z-index: 3;
}
.CodeMirror-selected,/*选中的背景*/
.CodeMirror-selectedtext {
    background: #666 !important;
}
.cm-s-inner .cm-tag{/*标签名字*/
    color: #F07178;
}
.cm-s-inner .cm-bracket{/*标签尖括号*/
    color: #EEE;
}
.cm-s-inner .cm-attribute{/*属性*/
    color: #FFCB6B;
}

/*对java部分的特色配色*/
pre[lang="java"] .cm-variable{
    color: #EEE;
}

行内代码样式

效果对比


在这里插入图片描述


在这里插入图片描述


.md-pair-s code{
    color: #42b983;
    font-weight: 600;
    background-color: transparent;
    border: none;
    font-family: "Source Sans Pro", "Helvetica Neue", Arial, sans-serif;
    font-size: 1em;
}

所有代码汇总

/*标题自动添加序号*/
.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;
}
/*因为不同主题的代码块部分不一样,code部分统一*/
.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;
}


/*MAC的三个图标*/

#write .md-fences:not([mermaid-type]):before {
    content: "";
    z-index: 4;
    display: block;
    position: absolute;
    top: 7px;
    left: 13px;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    float: left;
    background-color: #fa3534;
}

.md-fences:not([mermaid-type]) .cm-s-inner{
    padding-top: 30px;
}

.md-fences:not([mermaid-type]) .cm-s-inner:before {
    content: "";
    display: block;
    position: absolute;
    top: 0px;
    left: 29px;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    float: left;
    z-index: 4;
    background-color: #ff9900;
}
#write .md-fences:not([mermaid-type])::after {
    content: "";
    z-index: 4;
    display: block;
    position: absolute;
    top: 7px;
    left: 53px;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    float: left;
    background-color: #19be6b;
}

/*配色*/
.cm-s-inner .cm-number,/*数字*/
.cm-s-inner .cm-property {/*被调用的方法*/
    color: #f08d49 !important;
}
.cm-s-inner .cm-variable-3,/*形参,类型*/
.cm-s-inner .cm-qualifier,/*css class*/
.cm-s-inner .cm-variable-2 {/*被使用的形参*/
    color: #FFCB6B;
}
.cm-s-inner .cm-meta,/*省略号,注解等*/
.cm-s-inner .cm-atom,/*css属性值,布尔值等等*/
.cm-s-inner .cm-keyword{/*关键字*/
    color: #cc99cd;
}
.cm-s-inner .cm-def,/*变量名*/
.cm-s-inner .cm-variable {/*被使用的变量名*/
    color: #FFCB6B;
}
.cm-s-inner .cm-builtin {/*被调用的属性,php中是被调用的函数*/
    color: #82AAFF;
}
.cm-s-inner .cm-comment {/*注释*/
    color: #888;
}
.cm-s-inner .cm-string,/*字符串*/
.cm-s-inner .cm-type,/*类型*/
.cm-s-inner .cm-string-2 {/*正则表达式*/
    color: #7ec699
}
.CodeMirror-line .cm-operator {/*运算符*/
    color: #67cdcc
}
.CodeMirror div.CodeMirror-cursor {/*光标*/
    border-left: 1px solid #EEE;
    z-index: 3;
}
.CodeMirror-selected,/*选中的背景*/
.CodeMirror-selectedtext {
    background: #666 !important;
}

/*html*/
.cm-s-inner .cm-tag{/*标签名字*/
    color: #F07178;
}
.cm-s-inner .cm-bracket{/*标签尖括号*/
    color: #EEE;
}
.cm-s-inner .cm-attribute{/*属性*/
    color: #FFCB6B;
}
pre[lang="java"] .cm-variable{
    color: #EEE;
}

.md-pair-s code{
    color: #42b983;
    font-weight: 600;
    background-color: transparent;
    border: none;
    font-family: "Source Sans Pro", "Helvetica Neue", Arial, sans-serif;
    font-size: 1em;
}
  • 15
    点赞
  • 31
    收藏
    觉得还不错? 一键收藏
  • 14
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 14
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值