隐藏页面特效

自定义typora主题样式

1|0自定义typora主题样式


​ 上次看到别人使用的typora主题跟我的不一样,还有背景图片,然后下载使用了他的主题,结果竟然没有妹子,作为一个老二刺螈这能忍?参考了一下他修改的样式,我这里以github.css主题为例,基本翻译了这个css的内容,即使没有css基础的也可以直接拿来二次加工(末尾贴上全部css)。有大佬的话可以直接去修改一份base.css和base-control.css文件来自定义主题(在C:\Program Files\Typora\resources\style中)。(css对我这个小垃圾来说是真挺难搞)

修改部分包括:

  1. h1~h6标签内容居中(包括选中编辑状态下也居中)
  2. 修改默认字体样式
  3. 自定义颜色名称,并修改选中字体的背景颜色(包括代码块内选中的背景色修改以及高亮部分颜色修改)
  4. 添加背景(包括主题和代码块)
  5. 右键菜单颜色

其他可修改部分:

  1. 水平分割线样式修改
  2. 代码块背景色
  3. 有序列表、无序列表修改
  4. 任务列表修改
  5. 表格样式修改
  6. 目录样式修改

先上效果图(选中部分):

test:插入引用

h标签

2|0准备工作


打开Typora ==》左上角选择文件 ==》选择外观 ==》打开主题文件夹 ==》拷贝一份github.css文件

OK,打开css文档,开始修改!(建议用编辑器打开,个人使用的是hbuilderx,VScode也可以)

3|0h1~h6标签内容居中


定位到h1~h6标签的位置,添加一行代码 text-align: center;

h1, h2, h3, h4, h5, h6 { position: relative; margin-top: 1rem; margin-bottom: 1rem; font-weight: bold; /*修改字体颜色 color:#000; */ line-height: 1.4; cursor: text; text-align: center; /*h1~h6标签居中*/ }

这只是将字体的在默认状态下居中显示,但是在修改编辑的时候,还是会跳到默认的最左侧,修改如下:

/*正在编辑的h标签字体也居中*/ h1,[mdlike=h1] { text-align: center; font-family: "华文行楷", serif; font-size: 2.33em; line-height: 1.5; border-bottom: 1px solid #eee; } h2,[mdlike=h2] { text-align: center; font-family: "华文行楷", serif; font-size: 1.75em; line-height: 1.225; border-bottom: 1px solid #eee; } h3,[mdlike=h3] { text-align: center; font-family: "华文行楷", serif; font-size: 1.5em; line-height: 1.43; } h4,[mdlike=h4] { text-align: center; font-family: "华文行楷", serif; font-size: 1.25em; } h5,[mdlike=h5] { text-align: center; font-family: "华文行楷", serif; font-size: 1em; } h6,[mdlike=h6] { text-align: center; font-family: "华文行楷", serif; font-size: 1em; /*color: #777;*/ }

4|0修改默认字体样式


@font-face{} 修改字体样式,可以看到它引用了本地已经下载好的字体,就在主题文件夹里面的几个字体样式,可以直接替换字体样式就可以了。

也可以直接修改代码中的font-family属性,可以使用自带的字体,我这里将标题的字体改成了“华文行楷“,将引用的字体改成了”华文隶书”

test:插入引用

5|0自定义颜色名称,并修改选中字体的背景颜色


自定义颜色,在root中定义的,使用的时候只要 加上:var(--自定义颜色名称) 即可

:root { /* 自定义颜色 */ --mycolor1: #d1ff79; /*背景颜色、高亮等*/ --mycolor2: #efffe5; --mycolor3: #DDD5DB; /*艾米利亚头发颜色*/ --mycolor4: #B4D0F2; /*雷姆头发颜色*/ --yellow: #f2dc76; --blue: #8C99DC; --grey: #6D6A75; --black: #000000; --purple:#8a62a8; }

这里修改颜色我为了不打乱它的布局格式,统一都在css末尾添加的(理论上放哪好像都行)。

修改普通文本选中颜色:颜色可以自定义,直接复制粘贴

/* 选中高亮 */ ::selection { background-color: var(--mycolor1); }

typora自带有个选中高亮的,我们也给它改掉,直接复制粘贴

/* 修改背景高亮 */ mark { background-color: var(--mycolor1); /* color: #000; */ }

除此之外当我们给字体加粗(ctrl + B) 的时候也添加一个背景颜色,直接复制粘贴:

/* ctrl B 加粗时背景高亮 */ strong{ background-color: var(--mycolor1); }

6|0添加背景


这个是重点!

首先我没有按照我参考的大佬那样 将人物贴在白纸上,然后将白纸作为背景图片,因为我发现那个做有个弊端,就是在typora窗口不是最大化的时候,竖着方向拉伸,会出现黑色默认背景,会覆盖我们的内容,很不协调。

我这里的解决方案是:设置两个背景,第一个是一张白色的背景板,x,y方向都repeat;

第二个是我们的二次元人物png免扣图,手动调位置positon调到右下角。

解决方法是好的,但是也带来了一个问题,就是:不同尺寸的屏幕,人物位置可能不在右下角,因此需要自己手动调试位置(建议先在开发者工具中定位到图片位置调参数,然后直接覆盖到css中就行了)

这里我实在解决不好,可能跟css定位啥的有关吧,毕竟我也只是半吊子,哪位大佬解决了麻烦告知一下。

我辛辛苦苦用ps扣的,图片我放博客上了,建议下载下来用本地的。地址如下,需要自取:

雷姆免抠图

艾米利亚免抠图

派蒙

初音未来

蒂法

王者荣耀-嫦娥的图片有点大,还特意学习了怎么设置图床,hhh

王者荣耀-嫦娥

接下来就是放到背景中,这里有几处都能放,添加的位置不同,最后结果也不一样;

我这里直接放在html下(注意 艾米利亚的图片没有显示出来的话,是因为我使用了本地的艾米利亚图片,将图片下载下来或者使用网络资源修改下url路径即可):

html { font-size: 16px; -webkit-font-smoothing: antialiased; /* 第一张是人物头像,第二张是白纸,建议下载下来使用本地url路径,不然在没网或者网络不好的情况下可能加载不出来*/ /*使用本地url,我这里在themes目录下新建了一个image文件夹,将图片放到里面即可*/ /*background: url("image/雷姆.png") no-repeat, */ background: url("https://images.cnblogs.com/cnblogs_com/destiny-2015/2205159/o_220918074108_%E9%9B%B7%E5%A7%86%E5%85%8D%E6%8A%A0%E5%9B%BE.png") no-repeat, url("https://images.cnblogs.com/cnblogs_com/destiny-2015/2205159/o_220818071436_11.png") repeat; /* 位置可能不一样。建议根据自己屏幕大小修改位置 */ background-position: 108% 100%, 50% 50%; background-size: 20%; background-attachment: fixed, scroll; }

第二步,给代码块设置背景图片;定位到 .CodeMirror-lines:

/* 代码背景 代码在代码块上层*/ .CodeMirror-lines { padding-left: 4px; background: url(image/艾米利亚.png) no-repeat; background-position: 100% 102%; background-size: 15%; background-attachment: scroll; /* max-width: 90%; */ }

7|0右键菜单颜色


这个在github.css中好像也没有设置,我们需要自己添加以下:

/* 右键菜单栏 */ .dropdown-menu, .context-menu { background-color: var(--mycolor4); /* 菜单左侧边栏 */ border-left: 10px solid var(--blue); } .dropdown-menu .active, .context-menu .active { background-color: var(--mycolor4); color: var(--mycolor4); } /* 右键菜单栏选中 悬浮 */ /**/ .menu-style-btn.active, .context-menu.dropdown-menu > .active > a { background-color: var(--blue); } .context-menu.dropdown-menu > li > a:hover { background-color: var(--blue); color: var(--mycolor4); }

其他的基本上都在代码里,可以自己看着改,我就不写了,告辞!

  1. 修改 引用 在 第249行,“blockquote”,我这里用的 样式二
  2. 修改 表格 在 第346行
  3. 修改 任务列表 在 第444行
  4. 修改 目录 在 第528行

8|0mygithub.css


:root { /* 自定义颜色 */ --mycolor1: #d1ff79; /*背景颜色、高亮等*/ --mycolor2: #efffe5; --mycolor3: #DDD5DB; /*艾米利亚头发颜色*/ --mycolor4: #B4D0F2; /*雷姆头发颜色*/ --yellow: #f2dc76; --blue: #8C99DC; --grey: #6D6A75; --black: #000000; --purple:#8a62a8; } @include-when-export url(./github_1.css); /* open-sans-regular - latin-ext_latin */ /* 字体 */ @font-face { font-family: 'Open Sans'; font-style: normal; font-weight: normal; src: local('Open Sans Regular'), local('OpenSans-Regular'), url('./github/open-sans-v17-latin-ext_latin-regular.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD, U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF; } /* open-sans-italic - latin-ext_latin */ @font-face { /* 字体类型 */ font-family: 'Open Sans'; /* 正常还是斜体 */ font-style: italic; /* 字体粗细 */ font-weight: normal; src: local('Open Sans Italic'), local('OpenSans-Italic'), url('./github/open-sans-v17-latin-ext_latin-italic.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD, U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF; } /* open-sans-700 - latin-ext_latin */ @font-face { font-family: 'Open Sans'; font-style: normal; font-weight: bold; src: local('Open Sans Bold'), local('OpenSans-Bold'), url('./github/open-sans-v17-latin-ext_latin-700.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD, U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF; } /* open-sans-700italic - latin-ext_latin */ @font-face { font-family: 'Open Sans'; font-style: italic; font-weight: bold; src: local('Open Sans Bold Italic'), local('OpenSans-BoldItalic'), url('./github/open-sans-v17-latin-ext_latin-700italic.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD, U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF; } html { font-size: 16px; -webkit-font-smoothing: antialiased; /* 第一张是人物头像,第二张是白纸*/ /*使用本地url,我这里在themes目录下新建了一个image文件夹,将图片放到里面即可*/ background: url("https://images.cnblogs.com/cnblogs_com/destiny-2015/2205159/o_220918074108_%E9%9B%B7%E5%A7%86%E5%85%8D%E6%8A%A0%E5%9B%BE.png") no-repeat, url("https://images.cnblogs.com/cnblogs_com/destiny-2015/2205159/o_220818071436_11.png") repeat; /* 位置可能不一样。建议根据自己屏幕大小修改位置 */ background-position: 108% 100%, 50% 50%; background-size: 20%; background-attachment: fixed, scroll; } body { font-family: "Open Sans", "Clear Sans", "Helvetica Neue", Helvetica, Arial, 'Segoe UI Emoji', sans-serif; color: rgb(51, 51, 51); line-height: 1.6; } /* 设置正文纸张,就是版心大小 建议设置最大宽度自适应 */ #write { max-width: 860px; margin: 0 auto; padding: 30px; padding-bottom: 100px; /* max-width: 90%; */ } /* 媒体 */ /* @media only screen and (min-width: 1400px) { #write { max-width: 1024px; } } @media only screen and (min-width: 1800px) { #write { max-width: 1200px; } } */ @media screen and (min-width: 25cm) { #write { /* Make it a page width: 21cm;*/ min-height: 29.7cm; margin-left: 2cm; margin-right: 1.5cm; box-shadow: 20px 20px 40px rgba(0, 0, 0, 0.5); /* Add columns column-count: 2; column-gap: 0.5cm; column-width: 8cm;*/ /* Alignment */ text-align: left; } } #write>ul:first-child, #write>ol:first-child { margin-top: 30px; } /* 链接 */ a { color: #4183C4; text-decoration: none; } /* a链接悬空 */ a:hover { background-color: #d1ff79; color: #000; } /* 标题 */ h1, h2, h3, h4, h5, h6 { position: relative; margin-top: 1rem; margin-bottom: 1rem; font-weight: bold; line-height: 1.4; cursor: text; text-align: center; /*h1~h6标签居中*/ } h1:hover a.anchor, h2:hover a.anchor, h3:hover a.anchor, h4:hover a.anchor, h5:hover a.anchor, h6:hover a.anchor { text-decoration: none; } h1 tt, h1 code { font-size: inherit; } h2 tt, h2 code { font-size: inherit; } h3 tt, h3 code { font-size: inherit; } h4 tt, h4 code { font-size: inherit; } h5 tt, h5 code { font-size: inherit; } h6 tt, h6 code { font-size: inherit; } /*正在编辑的h标签字体也居中*/ h1,[mdlike=h1] { text-align: center; font-family: "华文行楷", serif; font-size: 2.33em; line-height: 1.5; border-bottom: 1px solid #eee; } h2,[mdlike=h2] { text-align: center; font-family: "华文行楷", serif; font-size: 1.75em; line-height: 1.225; border-bottom: 1px solid #eee; } h3,[mdlike=h3] { text-align: center; font-family: "华文行楷", serif; font-size: 1.5em; line-height: 1.43; } h4,[mdlike=h4] { text-align: center; font-family: "华文行楷", serif; font-size: 1.25em; } h5,[mdlike=h5] { text-align: center; font-family: "华文行楷", serif; font-size: 1em; } h6,[mdlike=h6] { text-align: center; font-family: "华文行楷", serif; font-size: 1em; /*color: #777;*/ } /*让选中正在编辑的标题居中*/ /* [mdlike=h1],[mdlike=h2],[mdlike=h3],[mdlike=h4],[mdlike=h5],{ text-align: center; } */ /* blockquote:引用 */ p, blockquote, ul, ol, dl, table { margin: 0.8em 0; } li>ol, li>ul { margin: 0 0; } hr { height: 2px; padding: 0; margin: 16px 0; background-color: #dfe2e5; border: 0 none; overflow: hidden; box-sizing: content-box; } li p.first { display: inline-block; } ul, ol { padding-left: 30px; } ul:first-child, ol:first-child { margin-top: 0; } ul:last-child, ol:last-child { margin-bottom: 0; } /* 引用的样式 */ /* blockquote { border-left: 4px solid #dfe2e5; padding: 0 15px; color: var(--mycolor1); } */ /*自定义引用样式一*/ /* blockquote { text-align: left; margin: 1.5em 10px; padding: 0.5em 10px; position: relative; background: #efffe5; padding-left: 24px; } blockquote:before { content: open-quote; font-size: 40px; text-align: center; line-height: 40px; color: #fff; position: absolute; border-radius: 25px; left: -25px; vertical-align: -0.2em; display: block; height: 25px; width: 25px; background-color: #555; font-style: normal; transition: all 350ms; } */ /* 自定义引用样式二 */ blockquote { break-inside: avoid; margin: 5mm 0; padding: 4mm; background-color: var(--mycolor4); border-top: 5px solid var(--mycolor3); border-bottom: 5px solid var(--mycolor3); font-family: "华文隶书", serif; letter-spacing: 0.75px; } blockquote > h4, blockquote > h3 { margin-block-start: 0.2em; } /* 表格部分 */ table { padding: 0; word-break: initial; } /* 标题栏 */ table tr { border: 1px solid #dfe2e5; margin: 0; padding: 0; } /* 标题栏开始隔一行添加背景色 */ table tr:nth-child(2n), thead { background-color: #f8f8f8; } /* 单元格 */ table th { font-weight: bold; border: 1px solid #dfe2e5; border-bottom: 0; margin: 0; padding: 6px 13px; } /* 行 */ table td { border: 1px solid #dfe2e5; margin: 0; padding: 6px 13px; } /* 第一列 */ table th:first-child, table td:first-child { margin-top: 0; } /* 最后一列 */ table th:last-child, table td:last-child { margin-bottom: 0; } /* 代码背景 代码在代码块上层*/ .CodeMirror-lines { padding-left: 4px; /*使用本地url,我这里在themes目录下新建了一个image文件夹,将图片放到里面即可*/ background: url(image/艾米利亚.png) no-repeat; background-position: 100% 102%; background-size: 15%; background-attachment: scroll; /* max-width: 90%; */ } /* 修改代码块内选中部分背景颜色 */ .CodeMirror-selected, .CodeMirror-selectedtext { background-color: #d1ff79 !important; } /* 代码块右下角 选择语言部分*/ .code-tooltip { box-shadow: 0 1px 1px 0 rgba(0, 28, 36, .3); border-top: 1px solid #eef2f2; } .md-fences, code, tt { border: 1px solid #e7eaed; background-color: #f8f8f8; border-radius: 7px; padding: 0; padding: 2px 4px 0px 4px; 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 */ padding-bottom: 6px; /* 背景板四角圆润 */ border-radius: 15px; } /* 任务列表 默认样式,可以自定义*/ .md-task-list-item {} .md-task-list-item>input { margin-left: -3.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; } .md-mathjax-midline { background: #fafafa; } #write>h3.md-focus:before { left: -1.5625rem; top: .375rem; } #write>h4.md-focus:before { left: -1.5625rem; top: .285714286rem; } #write>h5.md-focus:before { left: -1.5625rem; top: .285714286rem; } #write>h6.md-focus:before { left: -1.5625rem; top: .285714286rem; } .md-image>.md-meta { /*border: 1px solid #ddd;*/ border-radius: 3px; padding: 2px 0px 0px 4px; font-size: 0.9em; color: inherit; } .md-tag { color: #a7a7a7; opacity: 1; } /* 目录 */ .md-toc { margin-top: 20px; padding-bottom: 20px; } /* 悬空目录添时加下划线 修改为none */ .md-toc-inner:hover { text-decoration: none; } .sidebar-tabs { border-bottom: none; } #typora-quick-open { border: 1px solid #ddd; background-color: #f8f8f8; } #typora-quick-open-item { background-color: #FAFAFA; border-color: #FEFEFE #e5e5e5 #e5e5e5 #eee; border-style: solid; border-width: 1px; } /** focus mode */ .on-focus-mode blockquote { border-left-color: rgba(85, 85, 85, 0.12); } header, .context-menu, .megamenu-content, footer { font-family: "Segoe UI", "Arial", sans-serif; } .file-node-content:hover .file-node-icon, .file-node-content:hover .file-node-open-state { visibility: visible; } .mac-seamless-mode #typora-sidebar { background-color: #fafafa; background-color: var(side-bar-bg-color); } .md-lang { color: #b4654d; } /*.html-for-mac { --item-hover-bg-color: #E6F0FE; }*/ #md-notification .btn { border: 0; } .modal-content { background-color: var(--mycolor4); padding: 1rem; border: none; border-left: 10px solid var(--mycolor3); } .dropdown-menu .divider { border-color: #e5e5e5; opacity: 0.4; } /* 右键菜单栏 */ .dropdown-menu, .context-menu { background-color: var(--mycolor4); /* 菜单左侧边栏 */ border-left: 10px solid var(--blue); } .dropdown-menu .active, .context-menu .active { background-color: var(--mycolor4); color: var(--mycolor4); } /* 右键菜单栏选中 悬浮 */ /**/ .menu-style-btn.active, .context-menu.dropdown-menu > .active > a { background-color: var(--blue); } .context-menu.dropdown-menu > li > a:hover { background-color: var(--blue); color: var(--mycolor4); } /* 插入表格确认和取消按钮的背景 */ .btn, .btn-danger, .searchpanel-search-option-btn { background-color: var(--mycolor4); border: none; /* margin: 0.5rem; */ } .btn-primary{ color:#000000; border: none; } /* 插入时 表格行列 */ /* .input-group-addon { background-color: var(--mycolor4); } */ .ty-preferences .window-content { background-color: #fafafa; } .ty-preferences .nav-group-item.active { color: white; background: #999; } .menu-item-container a.menu-style-btn { background-color: #f5f8fa; background-image: linear-gradient(180deg, hsla(0, 0%, 100%, 0.8), hsla(0, 0%, 100%, 0)); } p .md-image:only-child { margin: 0 auto; text-align: center; } /* 选中高亮 */ ::selection { background-color: var(--mycolor1); } /* 修改背景高亮 */ mark { background-color: var(--mycolor1); /* color: #000; */ } /* ctrl B 加粗时背景高亮 */ strong{ background-color: var(--mycolor1); } /* .footnote-line{ color:#aaa; } */

参考:
少数派
typora设置主题和添加背景图片


__EOF__

本文作者Destiny-2015
本文链接https://www.cnblogs.com/destiny-2015/p/16705141.html
关于博主:评论和私信会在第一时间回复。或者直接私信我。
版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
声援博主:如果您觉得文章对您有帮助,可以点击文章右下角推荐一下。您的鼓励是博主的最大动力!
posted @   destiny-2015  阅读(560)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· 字符编码:从基础到乱码解决
· 提示词工程——AI应用必不可少的技术
点击右上角即可分享
微信分享提示