Skip to content

css定制

css定制

image-20231021104629256

目录

[toc]

个人定制css原则

  • 橙黄色主色调,简约美观

自定义typora主题

参考链接

https:.md-fences{padding-top:30px;background-color:var(--code-top-background-color);border:var(--code-border);border-radius:var(--code-border-radius);}.md-fences::before{position:absolute;left:10px;top:8px;content:'';width:15px;height:15px;border-radius:50%;background:rgb(252,98,93);box-shadow:25px0pxrgb(253,188,64),50px0pxrgb(53,205,75);}.cm-s-inner.CodeMirror{margin:0px;padding:6px;font-family:var(--code-font-family);font-size:var(--code-font-size);font-weight:var(--code-font-weight);color:var(--code-color);background-color:var(--code-body-background-color);border-top:1pxsolidvar(--code-body-border-top-color);border-bottom-left-radius:var(--code-border-radius);border-bottom-right-radius:var(--code-border-radius);}.cm-s-inner.CodeMirror-linenumber{color:var(--code-linenum-color);font-weight:var(--code-linenum-font-weight);}#write.CodeMirror-cursors.CodeMirror-cursor{border-left:var(--code-cursor-border);}.CodeMirror-wrap.CodeMirror-codepre{border-left:var(--code-divided-line-border);}.md-fences.code-tooltip{padding:0px;background-color:var(--code-inputbox-color);}.code-tooltip.ty-input{border:var(--code-inputbox-border);}.code-tooltip.ty-input:focus{border:var(--code-inputbox-focus-border);}.md-fences.md-focus.CodeMirror-code>div.CodeMirror-activeline{background-color:var(--code-selected-line-color);}.cm-s-inner.CodeMirror-selected{background-color:var(--code-selected-code-color) !important;}.cm-s-inner.CodeMirror-selectedtext{background-color:transparent!important;}.cm-s-inner.cm-keyword{color:#c792ea!important;}.cm-s-inner.cm-operator{color:#89ddff!important;}.cm-s-inner.cm-variable-2{color:#eeffff!important;}.cm-s-inner.cm-variable-3{color:#f07178!important;}.cm-s-inner.cm-type{color:#f07178!important;}.cm-s-inner.cm-builtin{color:#ffcb6b!important;}.cm-s-inner.cm-atom{color:#f78c6c!important;}.cm-s-inner.cm-number{color:#ff5370!important;}.cm-s-inner.cm-def{color:rgb(130,170,255) !important;}.cm-s-inner.cm-string{color:#a2c077!important;}.cm-s-inner.cm-string-2{color:#f07178!important;}.cm-s-inner.cm-comment{color:#fff!important;}.cm-s-inner.cm-variable{color:#f07178!important;}.cm-s-inner.cm-tag{color:#ff5370!important;}.cm-s-inner.cm-meta{color:#ffcb6b!important;}.cm-s-inner.cm-attribute{color:#c792ea!important;}.cm-s-inner.cm-property{color:#c792ea!important;}.cm-s-inner.cm-qualifier{color:#decb6b!important;}.cm-s-inner.cm-variable-3,.cm-s-inner.cm-type{color:#decb6b!important;}.cm-s-inner.cm-error{color:#fff!important;background-color:#ff5370!important;}--code-font-family:'Consolas';--code-font-size:0.9rem;--code-font-weight:400;--code-color:#a6accd;--code-border:1px solid #000;--code-border-radius:10px;--code-top-background-color:rgb(33,37,43);--code-body-background-color:rgb(41,45,62);--code-body-border-top-color:rgba(167,178,189,0.2);--code-linenum-color:#f0ad4e;--code-linenum-font-weight:500;--code-cursor-border:2px solid #fff;--code-divided-line-border:1px solid white;--code-inputbox-color:rgba(167,178,189,0.2);--code-inputbox-border:2px solid #000;--code-inputbox-focus-border:2px solid #61abff;--code-selected-line-color:rgba(167,178,189,0.2);--code-selected-code-color:rgba(167,178,189,0.2);

image-20240517214317798

范例:仿mac图标(白色)

  • 效果

image-20240517213953153

  • 配置方法
css
.md-fences::before{content:"";display:block;background:url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZlcnNpb249IjEuMSIgIHg9IjBweCIgeT0iMHB4IiB3aWR0aD0iNDUwcHgiIGhlaWdodD0iMTMwcHgiPgogIDxlbGxpcHNlIGN4PSI2NSIgY3k9IjY1IiByeD0iNTAiIHJ5PSI1MiIgc3Ryb2tlPSJyZ2IoMjIwLDYwLDU0KSIgc3Ryb2tlLXdpZHRoPSIyIiBmaWxsPSJyZ2IoMjM3LDEwOCw5NikiLz4KICA8ZWxsaXBzZSBjeD0iMjI1IiBjeT0iNjUiIHJ4PSI1MCIgcnk9IjUyIiAgc3Ryb2tlPSJyZ2IoMjE4LDE1MSwzMykiIHN0cm9rZS13aWR0aD0iMiIgZmlsbD0icmdiKDI0NywxOTMsODEpIi8+CiAgPGVsbGlwc2UgY3g9IjM4NSIgY3k9IjY1IiByeD0iNTAiIHJ5PSI1MiIgIHN0cm9rZT0icmdiKDI3LDE2MSwzNykiIHN0cm9rZS13aWR0aD0iMiIgZmlsbD0icmdiKDEwMCwyMDAsODYpIi8+Cjwvc3ZnPg==);height:30px;width:100%;background-size:40px;background-repeat:no-repeat;background-color:#f8f8f8;border-radius:5px5px00;background-position:6px10px;}.cm-s-inner.CodeMirror{background:#f8f8f8;border-radius:005px5px;padding:20px10px20px20px;page-break-before:auto;line-height:1.65rem;}

image-20240517214040670

示例:github主题代码风格

  • 配置方法

img

css
.CodeMirror-lines{padding-left:4px;}.code-tooltip{box-shadow:01px1px0rgba(0,28,36,.3);border-top:1pxsolid#eef2f2;}.md-fences,code,tt{border:1pxsolid#e7eaed;background-color:#f8f8f8;border-radius:3px;padding:0;padding:2px4px0px4px;font-size:0.9em;}
  • 效果展示

img

示例:material主题代码风格

  • 配置方法

img

css
.cm-s-inner{background-color:#382f26;color:rgba(233,237,237,1);}.cm-s-inner.CodeMirror-gutters{background:#263238;color:rgb(83,127,126);border:none;}.cm-s-inner.CodeMirror-guttermarker,.cm-s-inner.CodeMirror-guttermarker-subtle,.cm-s-inner.CodeMirror-linenumber{color:rgb(83,127,126);}.cm-s-inner.CodeMirror-cursor{border-left:1pxsolid#f8f8f0;}.cm-s-innerdiv.CodeMirror-selected{background:rgba(255,255,255,0.15);}.cm-s-inner.CodeMirror-focuseddiv.CodeMirror-selected{background:rgba(255,255,255,0.10);}.cm-s-inner.CodeMirror-line::selection,.cm-s-inner.CodeMirror-line>span::selection,.cm-s-inner.CodeMirror-line>span>span::selection{background:rgba(255,255,255,0.10);}.cm-s-inner.CodeMirror-line::-moz-selection,.cm-s-inner.CodeMirror-line>span::-moz-selection,.cm-s-inner.CodeMirror-line>span>span::-moz-selection{background:rgba(255,255,255,0.10);}.cm-s-inner.CodeMirror-activeline-background{background:rgba(0,0,0,0);}.cm-s-inner.cm-keyword{color:rgba(199,146,234,1);}.cm-s-inner.cm-operator{color:rgba(233,237,237,1);}.cm-s-inner.cm-variable-2{color:#80CBC4;}.cm-s-inner.cm-variable-3{color:#82B1FF;}.cm-s-inner.cm-builtin{color:#DECB6B;}.cm-s-inner.cm-atom{color:#F77669;}.cm-s-inner.cm-number{color:#F77669;}.cm-s-inner.cm-def{color:rgba(233,237,237,1);}.cm-s-inner.cm-string{color:#C3E88D;}.cm-s-inner.cm-string-2{color:#80CBC4;}.cm-s-inner.cm-comment{color:#546E7A;}.cm-s-inner.cm-variable{color:#82B1FF;}.cm-s-inner.cm-tag{color:#80CBC4;}.cm-s-inner.cm-meta{color:#80CBC4;}.cm-s-inner.cm-attribute{color:#FFCB6B;}.cm-s-inner.cm-property{color:#80CBAE;}.cm-s-inner.cm-qualifier{color:#DECB6B;}.cm-s-inner.cm-variable-3{color:#DECB6B;}.cm-s-inner.cm-tag{color:rgba(255,83,112,1);}.cm-s-inner.cm-error{color:rgba(255,255,255,1.0);background-color:#EC5F67;}.cm-s-inner.CodeMirror-matchingbracket{text-decoration:underline;color:white!important;}.md-fences{background-color:#263238;color:rgb(237,234,233);border:none;}.md-fences.code-tooltip{background-color:#263238;}.CodeMirror-lines{cursor:text;background-color:#232323;font-family:DejaVu Sans Mono,Monaco,'Courier New',monospace;}
  • 效果展示

img

示例:模拟mac的3个图标(白色)

  • 配置方法

img

css
\#write pre.md-fences{padding:1rem0.5rem1rem;display:block;-webkit-overflow-scrolling:touch;border-top:rgb(244,244,244) solid35px;background-color:rgb(244,244,244);}pre.md-fences::before{content:'';background:#fa3534;box-shadow:23px0#ff9900,45px0#19be6b;border-radius:50%;margin-top:-2.3rem;position:absolute;left:15px;height:12px;width:12px;}\#write pre.md-fences{line-height:1.5rem;font-size:0.9rem;font-weight:300;border-radius:.7em;font-family:DejaVu Sans Mono,Monaco,'Courier New',monospace;}
  • 效果展示

img

示例:模拟mac的3个图标(暗黑)

  • 配置方法

img

css
.CodeMirror-wrap.CodeMirror-scroll{padding-top:20px;}\#write .md-fences:before{content:"";z-index:4;display:block;position:absolute;top:7px;left:15px;height:12px;width:12px;border-radius:50%;float:left;background-color:#fa3534;}\#write .CodeMirror-scroll:before{content:"";display:block;position:absolute;top:0px;left:25px;height:12px;width:12px;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:55px;height:12px;width:12px;border-radius:50%;float:left;background-color:#19be6b;}
  • 效果展示

img

示例:修改代码背景颜色为sublime text3的背景色

  • 注意

注意:sublimet text3背景颜色的颜色代码为

background:#232323;这个颜色为sublime text3的颜色;

img

  • 配置方法

img

css
\#write .md-fences:not([mermaid-type]) {font-family:var(--monospace-font);font-size:1rem;font-weight:bold;padding:0.6rem;padding-top:7px;border-radius:10px;background-color:#232323;color:#eeeeee;border-radius:0.4rem;box-shadow:var(--block-shadow);}
  • 效果展示

img

示例:修改代码块字体

  • 配置方法

img

css
.md-fences,code,tt{background-color:#f8f8f8;border-radius:3px;padding:0;padding-left:4px!important;padding-right:4px!important;font-size:0.9em;font-family:consolas,'Courier New',monospace;}\#write .md-fences:not([mermaid-type]) {padding:0.6rem;padding-top:7px;border-radius:10px;background-color:#232323;color:#eeeeee;border-radius:0.4rem;box-shadow:var(--block-shadow);}

示例:typora的代码块的光标颜色配置(已配置)

  • 配置方法

img

css
.cm-s-inner.CodeMirror-cursor{border-left:solidrgb(96,255,96) !important;}
  • 效果展示

img

示例:设置代码块下边距

配置时间:2023年2月14日

这个功能并不是很友好,这里弃用;

  • 配置方法
css
.md-fences{font-family:"Fira Code",Consolas,"Lucida Console","Courier",monospace,"Helvetica Neue",Helvetica,Arial,sans-serif;background-color:#282c34;padding:6px10px;-webkit-box-shadow:02px5px0rgba(0,0,0,0.16),02px10px0rgba(0,0,0,0.12);box-shadow:02px5px0rgba(0,0,0,0.16),02px10px0rgba(0,0,0,0.12);margin-bottom:0.5rem;border:none;border-radius:6px;}

img

  • 效果展示

img

默认效果还是好一点:

img

行内代码块

案例

  • 配置方法

img

css
code{background-color:var(--code-background-color);border-radius:5px;padding:4px;color:var(--code-color);}
  • 效果展示

img

侧边栏

案例:配置侧边栏鼠标悬浮后颜色

  • 效果

image-20240516215147973

  • 配置方法

image-20240516215334397

css
.outline-item-active{background:#6fd18d;color:#fff;}.outline-contentli,.outline-contentul{margin:5px0!important;}.outline-item:hover{background-color:#bac6e9!important;}

示例:设置左侧目录字体

  • 配置方法

img

css
header,.context-menu,.megamenu-content,footer{font-family:"霞鹜文楷","SimSun","Arial",sans-serif;}
  • 效果展示

img

示例:typora左侧文档树搜索框颜色修改

  • 配置方法

img

css
input[type="search"i] {appearance:auto;box-sizing:border-box;padding:1px2px;background-color:#cc99cd;color:black;}

img

img

案例

  • 配置方法
css
.megamenu-menu-header{width:60%;text-align:center;border-bottom:solid3pxvar(--main-color);}\#megamenu-menu-sidebar{background-color:rgba(255,255,255,0.1);color:var(--sidebar-font-color);box-shadow:008px4pxrgb(100100100/ 80%);margin-top:3%;height:92%;border-radius:04em4em0;}\#megamenu-back-btn{border-radius:1.2em;color:var(--main-color);transition:alllinear.3s;padding:0010px;}\#megamenu-back-btn:hover{background-color:var(--main-color);color:white;border:2pxsolidwhite;transition:alllinear.3s;}\#megamenu-menu-list>li{transition:alllinear.3s;}\#megamenu-menu-list>li:hover{transition:alllinear.3s;border-top-left-radius:1.2em;border-bottom-left-radius:1.2em;}\#megamenu-menu-list>li:focus{transition:alllinear.3s;color:white;background-color:var(--shadow-color);width:fit-content;border-top-right-radius:1.2em;border-bottom-right-radius:1.2em;}.dropdown-menu.divider{width:30%;color:var(--main-color);background-color:var(--main-color);}.megamenu-menu-listlia{transition:alllinear.3s;width:fit-content;padding-right:60px;}.megamenu-menu-listlia:hover{transition:alllinear.3s;color:white!important;background-color:var(--main-color) !important;border-bottom-right-radius:2em;border-top-right-radius:2em;}.megamenu-menu-listlia.active,.megamenu-menu-list:not(.saved) lia:hover{color:white!important;background-color:var(--main-color) !important;border-bottom-right-radius:2em;border-top-right-radius:2em;}\#m-open-local,\#m-import-local{border-radius:1.2em;}\#m-open-local:hover,\#m-import-local:hover{border:1pxsolidvar(--shadow-color);}\#recent-file-panel-search-input{border-radius:1.2em;transition:alllinear.3s;font-family:var(--title-font);}\#recent-file-panel-action-btn{border-radius:1.2em;}\#recent-file-panel-search-input:hover{transition:alllinear.3s;box-shadow:0010px3pxvar(--shadow-color);}\#recent-file-panel-search-input:focus{transition:alllinear.3s;color:white;border:none;background-color:var(--shadow-color);}.info-panel-tab-border{color:var(--main-color) !important;background-color:var(--main-color) !important;}.outline-content{padding:3px18px3px0;}.outline-item{margin-left:-20px;margin-right:-20px;border-left:20pxsolidtransparent;border-right:16pxsolidtransparent;}.outline-item:hover{background-color:var(--shadow-color);color:white;}.active-tab-files#info-panel-tab-file.info-panel-tab-title{background-color:var(--main-color);color:white;padding:5px5px;border-radius:1.2em;transition:alllinear.3s;}.active-tab-outline#info-panel-tab-outline.info-panel-tab-title{background-color:var(--main-color);color:white;padding:5px5px;border-radius:1.2em;transition:alllinear.3s;}.ty-show-search#info-panel-tab-search.info-panel-tab-title{background-color:var(--main-color);color:white;padding:5px5px;border-radius:1.2em;transition:alllinear.3s;}\#file-library-search-input{border-radius:.5em;}\#file-library-search-input:focus{border:2pxsolidvar(--main-color);}.info-panel-tab-border{display:none;}div#file-library-list-children{transition:alllinear.3s;}.file-list-item.active{border-top-right-radius:2.2em;border-bottom-right-radius:2.2em;width:fit-content;background-color:var(--main-color) !important;color:white;transition:alllinear.3s;}.outline-item-active{border-top-right-radius:2.2em;border-bottom-right-radius:2.2em;width:fit-content;background-color:var(--main-color) !important;color:white;transition:alllinear.3s;}

img

示例:设置右侧滚动滑块的颜色

案例1:默认不添加代码

默认这个灰色效果会好一点,可以让人更关注文章内容本身。

img

案例2:有颜色的

  • 配置方法

img

css
::-webkit-scrollbar{width:8px;height:8px;}::-webkit-scrollbar-track{-webkit-box-shadow:inset006pxrgba(0,0,0,0.2);border-radius:8px;}::-webkit-scrollbar-thumb{border-radius:8px;background:pink;-webkit-box-shadow:inset006pxrgba(0,0,0,0.25);}
  • 效果展示

img

示例:大纲小三角图标设置

  • 配置方法

img

css
\#typora-sidebar#sidebar-loading-template.file-list-item{border-bottom:transparent!important;background-color:rgba(171,192,208,0.1);}\#typora-sidebar.info-panel-tab-wrapper.info-panel-tab:hover{color:inherit;}\#typora-sidebar.info-panel-tab-wrapper.info-panel-tab.info-panel-tab-border{background-color:#2f845e;border-radius:4px;}\#typora-sidebar.sidebar-osx-tab.sidebar-tabs{border-bottom-color:transparent;}\#typora-sidebar#sidebar-content.file-list-item{border-bottom:1pxsolid#eee;}\#typora-sidebar#sidebar-content.file-list-item.active{background-color:rgba(66,185,131,0.1);border-left:4pxsolid#2f845e;}\#typora-sidebar#sidebar-content.ty-sidebar-search-panel{border-bottom:1pxsolid#eee;}\#typora-sidebar#sidebar-content.ty-sidebar-search-panel.searchpanel-search-option-btn{background-color:#fff;}\#typora-sidebar#sidebar-content.sidebar-content-content.file-tree-node:not(.file-node-root):hover>.file-node-background{border-left:4pxsolid#2f845e;background-color:rgba(66,185,131,0.1);}\#typora-sidebar#sidebar-content.sidebar-content-content.file-tree-node.active>.file-node-background{border-color:#2f845e;background-color:rgba(66,185,131,0.1);}\#typora-sidebar#sidebar-content.sidebar-content-content#file-library-list-children.file-library-file-node:hover{border-left:4pxsolid#2f845e;background-color:rgba(66,185,131,0.1);}\#typora-sidebar#sidebar-content#outline-content.no-collapse-outline.outline-item{line-height:1.375rem;font-size:1rem;}\#typora-sidebar#sidebar-content#outline-content.outline-expander:before{color:inherit;font-size:14px;top:auto;content:"\f0da";font-family:FontAwesome;}\#typora-sidebar#sidebar-content#outline-content.outline-expander:hover:before,\#typora-sidebar#sidebar-content#outline-content.outline-item-open>.outline-item>.outline-expander:before{content:"\f0d7";}\#typora-sidebar#sidebar-content#outline-content.outline-item:hover{background-color:#bac6e9!important;}\#typora-sidebar#ty-sidebar-footer{border-top:1pxsolid#eee;}\#typora-sidebar#ty-sidebar-footer.sidebar-footer-item:hover{background-color:#bac6e9!important;}\#typora-sidebar#ty-sidebar-footer#sidebar-files-menu{-webkit-box-shadow:02px5px0rgba(0,0,0,0.16),02px10px0rgba(0,0,0,0.12);box-shadow:02px5px0rgba(0,0,0,0.16),02px10px0rgba(0,0,0,0.12);}
  • 效果展示

img

示例:控制 TOC 水平

css
在 Typora 中[TOC]会生成“目录”。默认情况下,它将显示从h1到 的标题h6。例如,要隐藏较低级别的标题,h6您可以附加以下 CSS:.md-toc-h6{display:none;}

示例:Typora侧边栏同时查看大纲和文件|添加TabBar

  • typora默认的布局

文件和文章目录只能显示一个,不能同时显示:

img

img

  • 希望实现的需求如下:

希望能后实现,typora显示的布局左边是文件列表,右边是文章目录:

img

  • 参考别人文章

https:.outline-item-active::after,.active.file-list-item-file-name::after,.active.file-node-content::after{content:"";position:absolute;top:calc(50%-4px);right:0;width:8px;height:8px;border-radius:50%;background:#0284c7;}

img

img

案例:修改侧边栏目录和文档图标

2024年9月18日测试

阿里巴巴矢量图标库:官网地址

这里使用的是阿里巴巴的矢量图标库为例,首先进入首页,点击资源管理--->我的项目,如图:

image-20240507124014171

①新建图标库项目

新建项目,填写完之后点击新建

image-20240507124033488

image-20240507124046585

②添加图标到项目

搜索自己喜欢的图标或者你项目要使用的图标,添加到购物车 -->添加至项目 -->选择刚刚创建的项目 -->确定

image-20240507124107368

点击确定之后会跳转到我们的项目列表

③下载图标源码

image-20240507124126474

解压之后会看到如下文件,我们这里需要的是iconfont.woff文件

image-20240507124145266

④自定义Typora图标

image-20240507124216737

以上是演示修改Typora左侧菜单栏的文件夹图标文件图标,其他字体图标原理相同。

fortunate.scss

scss
:root{......--fa-folder:"\e756";--fa-file:"\e7b4";}@font-face{font-family:'FontAwesome';src:url('./fortunate/iconfont.woff') format('woff');font-weight:normal;font-style:normal;}.fa{font-family:FontAwesome;font-size:1rem;}.fa-folder:before{content:var(--fa-folder);}.fa-file-text-o:before{content:var(--fa-file);}

重启Typora,效果如下:

image-20240918072344486

表格

案例

  • 配置方法

img

img

css
:root{--side-bar-bg-color:rgba(231,153,176,0.5);--window-border:2pxsolid#E799B0;--main-color:rgba(128,30,255,1);--shadow-color:rgb(178,80,255);--transplate-color:rgba(128,30,255,0.1);--dark-color:rgb(70,18,137);--light-color:rgb(248,242,255);--font-color:rgb(12,12,12);--base-font:"Glow Sans","Microsoft YaHei",serif;--title-font:"Roboto Slab","Times",serif;--blockquote-font:"Times","Roboto Slab",serif;--blockquote-color:rgba(117,117,117,0.9);--monospace:"Cascadia code","Courier New",monospace;--quote-title-font-size:0.9em;--quote-tag-font-size:1.1em;--sidebar-font-color:black;--main-panel-font-color:black;}\#write table{width:95%;border-collapse:collapse;text-align:center;font-family:var(--monospace);margin:20px;}\#write tabletd,tableth{border:1pxsolidtransparent;color:rgb(18,18,18);height:30px;padding:10px;border-radius:.5em;transition:all0.3slinear;-moz-transition:all0.3slinear;-webkit-transition:all0.3slinear;}\#write tabletd{font-family:var(--title-font);}\#write tabletheadth{background-color:var(--shadow-color);font-size:20px;color:white;font-weight:bolder;width:100px;text-align:center;vertical-align:middle;padding:10px;}tabletr:nth-child(odd){background:white;}tabletr:nth-child(even){background:var(--light-color);}tabletd:hover{background-color:var(--shadow-color) !important;color:white!important;box-shadow:0010px5pxvar(--shadow-color);transition:all0.3slinear;-moz-transition:all0.3slinear;-webkit-transition:all0.3slinear;}
  • 配置效果

img

图片

案例:居中、阴影

  • 效果

image-20240518055224644

  • 配置代码:
css
#writeimg{border-radius:20px;box-shadow:2px3px6px2px#8C8C8C;border:none!important;}.md-imageimg[alt|='shadow'] {border-radius:20px;box-shadow:2px3px6px2px#8C8C8C;border:none!important;}.md-imageimg[alt|='frame'] {border-radius:none!important;border:10pxsolid#ffffff;outline:1pxsolidvar(--img-outline-color);}#write{counter-reset:imgNum;}#writep>.md-image:after{counter-increment:imgNum;content:"图"counter(imgNum) attr(alt) !important;text-align:center;width:100%;display:inline-block;margin-top:8px!important;font-size:small;}

设置图片默认对齐方式

  • 默认情况,Typora的图片是居中对齐的。
  • 现在有个需求,想让每次哦插入的图片都默认做对齐,该如何实现呢?
  • 设置方法打开文件 - 偏好设置 - 外观 - 打开主题文件夹,选择你自己的主题名.css(默认是 Github.css),在最后插入 CSS 代码,保存退出,再次打开typora文件即可:

img

css
p.md-image:only-child{width:auto;text-align:left;}
  • 效果展示

img

给图片添加阴影个圆角功能

方法1

  • 配置方法
css
img{filter:drop-shadow(10px10px10pxgreen);border-radius:8px;}

img

  • 效果展示

img

方法2(荐)

  • 配置方法
css
\#write img{border-radius:1.5em!important;box-shadow:0010px3pxrgba(134,136,137,0.8);transition:all0.3slinear;-moz-transition:all0.3slinear;-webkit-transition:all0.3slinear;}

img

  • 效果展示

img

圆边角设置为20px看起来比较美观-2022.9.14

  • 配置方法

img

css
\#write img{border-radius:20px;box-shadow:2px3px6px2px#8C8C8C;border:none!important;}.md-imageimg[alt|='shadow'] {border-radius:20px;box-shadow:2px3px6px2px#8C8C8C;border:none!important;}.md-imageimg[alt|='frame'] {border-radius:none!important;border:10pxsolid#ffffff;outline:1pxsolidvar(--img-outline-color);}p.md-image:only-child{width:auto;text-align:left;}
  • 效果展示

img

图片自动编号

  • 配置方法

img

css
#write{counter-reset:imgNum;}#writep>.md-image:after{counter-increment:imgNum;content:"图"counter(imgNum) attr(alt) !important;text-align:center;width:100%;display:inline-block;margin-top:8px!important;font-size:small;}
  • 效果展示

img

  • 总结

加了图片自动编号后,会影响编辑体验的(点击图片的下方标识数字后,会有异常的显示的……),因此将禁止次功能。(2023年1月8日)

h1-h6

案例:小竖条

  • 效果如下

image-20231228215151243

  • 配置方法
css
h1,h2,h3,h4,h5,h6{position:relative;margin-top:0rem;margin-bottom:0rem;font-weight:bold;font-family:Gilroy,阿里巴巴普惠体,"Open Sans",Alibaba Sans !important;line-height:1.4;cursor:text;text-shadow:1px1px1pxrgba(0,0,0,0.2);}h1:hovera.anchor,h2:hovera.anchor,h3:hovera.anchor,h4:hovera.anchor,h5:hovera.anchor,h6:hovera.anchor{text-decoration:none;}h1tt,h1code{font-size:inherit!important;}h2tt,h2code{font-size:inherit!important;}h3tt,h3code{font-size:inherit!important;}h4tt,h4code{font-size:inherit!important;}h5tt,h5code{font-size:inherit!important;}h6tt,h6code{font-size:inherit!important;}h2a,h3a{color:#34495e;}h1{padding-bottom:0.4rem;font-size:2.2rem;line-height:1.3;position:relative;text-shadow:1px1px2pxrgba(0,0,0,0.2);}h1::before{content:"";display:block;background-color:#23a9f2;width:5px;height:32px;position:absolute;top:13px;left:-15px;border-radius:2px;box-shadow:1px1px2pxrgba(0,0,0,0.2);}h2::before{content:"";display:block;background-color:#ffbd2e;width:5px;height:30px;position:absolute;top:6px;left:-15px;border-radius:2px;box-shadow:1px1px2pxrgba(0,0,0,0.2);}h3{font-size:1.4rem;line-height:1.43;margin:5px05px;position:relative;text-shadow:1px1px2pxrgba(0,0,0,0.2);}h3::after{content:"";display:block;background-color:#27c93f;width:5px;height:20px;position:absolute;top:8px;left:-15px;border-radius:2px;box-shadow:1px1px2pxrgba(0,0,0,0.2);}h4{font-size:1.2rem;}h4::after{content:"";display:block;background-color:#ff5f56;width:5px;height:15px;position:absolute;top:8px;left:-15px;border-radius:2px;box-shadow:1px1px2pxrgba(0,0,0,0.2);}h5{font-size:1rem;}h5::after{content:"";display:block;background-color:purple;width:5px;height:15px;position:absolute;top:8px;left:-15px;border-radius:2px;box-shadow:1px1px2pxrgba(0,0,0,0.2);}h6{font-size:1rem;color:#777;}h6::after{content:"";display:block;background-color:plum;width:5px;height:15px;position:absolute;top:8px;left:-15px;border-radius:2px;box-shadow:1px1px2pxrgba(0,0,0,0.2);}h3.md-focus:before{width:auto;height:auto;color:rgb(50,9,212);background-color:#ff5d52;border:1pxsolid;border-radius:3px;position:absolute;left:-1.642857143rem;top:0.357142857rem;float:left;font-size:9px;padding-left:2px;padding-right:2px;vertical-align:bottom;font-weight:400;line-height:normal;}h4.md-focus:before{width:auto;height:auto;color:rgb(50,9,212);background-color:#ff5d52;border:1pxsolid;border-radius:3px;position:absolute;left:-1.642857143rem;top:0.357142857rem;float:left;font-size:9px;padding-left:2px;padding-right:2px;vertical-align:bottom;font-weight:400;line-height:normal;}h5.md-focus:before{width:auto;height:auto;color:rgb(50,9,212);background-color:#ff5d52;border:1pxsolid;border-radius:3px;position:absolute;left:-1.642857143rem;top:0.357142857rem;float:left;font-size:9px;padding-left:2px;padding-right:2px;vertical-align:bottom;font-weight:400;line-height:normal;}h6.md-focus:before{width:auto;height:auto;color:rgb(50,9,212);background-color:#ff5d52;border:1pxsolid;border-radius:3px;position:absolute;left:-1.642857143rem;top:0.357142857rem;float:left;font-size:9px;padding-left:2px;padding-right:2px;vertical-align:bottom;font-weight:400;line-height:normal;}

案例:重影

  • 配置方法
css
#writeh2{display:table;margin:30pxauto20pxauto;background-image:linear-gradient(toleft,rgb(253,213,231),rgb(194,226,249));border-style:solid;border-width:1px;border-radius:0px;border-color:rgb(62,62,62);}#writeh2.content{display:block;font-size:18px;border:1pxsolidblack;padding:10px;transform:translate3d(-5px,-5px,0px);}#writeh2.prefix{}#writeh2.suffix{}

img

  • 效果展示

img

本来理想效果应该是如下:

img

案例:给三级、四级、五级、六级 标题设置点击后左边的提示图标-2022.7.5

  • 配置方法
css
h1,h2,h3,h4,h5,h6{position:relative;margin-top:1rem;margin-bottom:1rem;font-weight:bold;line-height:1.4;cursor:text;}h1:hovera.anchor,h2:hovera.anchor,h3:hovera.anchor,h4:hovera.anchor,h5:hovera.anchor,h6:hovera.anchor{text-decoration:none;}h1tt,h1code{font-size:inherit!important;}h2tt,h2code{font-size:inherit!important;}h3tt,h3code{font-size:inherit!important;}h4tt,h4code{font-size:inherit!important;}h5tt,h5code{font-size:inherit!important;}h6tt,h6code{font-size:inherit!important;}h2a,h3a{color:#34495e;}h1span{display:inline-block;font-size:1.5rem;font-weight:bold;background:rgba(140,68,250,0.7);color:#0000FF;padding:3px10px1px;border-top-right-radius:3px;border-top-left-radius:3px;margin-top:15px;margin-bottom:15px;margin-right:3px;}h2span{display:inline-block;font-size:1.3rem;font-weight:bold;background:rgba(239,112,96,0.7);color:#0000FF;padding:3px10px1px;border-top-right-radius:3px;border-top-left-radius:3px;margin-top:5px;margin-bottom:5px;margin-right:3px;}h3span{font-size:1.1rem!important;display:inline-block;font-weight:bold;background:rgba(2,171,107,0.7);color:#0000FF;padding:3px10px1px;border-top-right-radius:3px;border-top-left-radius:3px;margin-right:3px;}h4{font-size:1rem;color:#0000FF;}h5{font-size:1rem;color:#0000FF;}h6{font-size:1rem;color:#0000FF;}p,blockquote,ul,ol,dl,table{margin:0.8em0;}li>ol,li>ul{margin:00;}body>h2:first-child{margin-top:0;padding-top:0;}body>h1:first-child{margin-top:0;padding-top:0;}body>h1:first-child+h2{margin-top:0;padding-top:0;}body>h3:first-child,body>h4:first-child,body>h5:first-child,body>h6:first-child{margin-top:0;padding-top:0;}a:first-childh1,a:first-childh2,a:first-childh3,a:first-childh4,a:first-childh5,a:first-childh6{margin-top:0;padding-top:0;}h1p,h2p,h3p,h4p,h5p,h6p{margin-top:0;}lip.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;}h3.md-focus:before{width:auto;height:auto;color:rgb(50,9,212);background-color:#ff5d52;border:1pxsolid;border-radius:3px;position:absolute;left:-1.642857143rem;top:0.357142857rem;float:left;font-size:9px;padding-left:2px;padding-right:2px;vertical-align:bottom;font-weight:400;line-height:normal;}h4.md-focus:before{width:auto;height:auto;color:rgb(50,9,212);background-color:#ff5d52;border:1pxsolid;border-radius:3px;position:absolute;left:-1.642857143rem;top:0.357142857rem;float:left;font-size:9px;padding-left:2px;padding-right:2px;vertical-align:bottom;font-weight:400;line-height:normal;}h5.md-focus:before{width:auto;height:auto;color:rgb(50,9,212);background-color:#ff5d52;border:1pxsolid;border-radius:3px;position:absolute;left:-1.642857143rem;top:0.357142857rem;float:left;font-size:9px;padding-left:2px;padding-right:2px;vertical-align:bottom;font-weight:400;line-height:normal;}h6.md-focus:before{width:auto;height:auto;color:rgb(50,9,212);background-color:#ff5d52;border:1pxsolid;border-radius:3px;position:absolute;left:-1.642857143rem;top:0.357142857rem;float:left;font-size:9px;padding-left:2px;padding-right:2px;vertical-align:bottom;font-weight:400;line-height:normal;}
  • 效果展示

img

案例:h1-h6级标题风格设置(边框版)-2022.7.4

  • 配置方法
css
h1,h2,h3,h4,h5,h6{position:relative;margin-top:1rem;margin-bottom:1rem;font-weight:bold;line-height:1.4;cursor:text;}h1:hovera.anchor,h2:hovera.anchor,h3:hovera.anchor,h4:hovera.anchor,h5:hovera.anchor,h6:hovera.anchor{text-decoration:none;}h1tt,h1code{font-size:inherit!important;}h2tt,h2code{font-size:inherit!important;}h3tt,h3code{font-size:inherit!important;}h4tt,h4code{font-size:inherit!important;}h5tt,h5code{font-size:inherit!important;}h6tt,h6code{font-size:inherit!important;}h2a,h3a{color:#34495e;}h1span{display:inline-block;font-size:1.5rem;font-weight:bold;background:rgba(140,68,250,0.7);color:#0000FF;padding:3px10px1px;border-top-right-radius:3px;border-top-left-radius:3px;margin-top:15px;margin-bottom:15px;margin-right:3px;}h2span{display:inline-block;font-size:1.3rem;font-weight:bold;background:rgba(239,112,96,0.7);color:#0000FF;padding:3px10px1px;border-top-right-radius:3px;border-top-left-radius:3px;margin-top:5px;margin-bottom:5px;margin-right:3px;}h3span{font-size:1.1rem!important;display:inline-block;font-weight:bold;background:rgba(2,171,107,0.7);color:#0000FF;padding:3px10px1px;border-top-right-radius:3px;border-top-left-radius:3px;margin-right:3px;}h4{font-size:1rem;color:#0000FF;}h5{font-size:1rem;color:#0000FF;}h6{font-size:1rem;color:#0000FF;}p,blockquote,ul,ol,dl,table{margin:0.8em0;}li>ol,li>ul{margin:00;}body>h2:first-child{margin-top:0;padding-top:0;}body>h1:first-child{margin-top:0;padding-top:0;}body>h1:first-child+h2{margin-top:0;padding-top:0;}body>h3:first-child,body>h4:first-child,body>h5:first-child,body>h6:first-child{margin-top:0;padding-top:0;}a:first-childh1,a:first-childh2,a:first-childh3,a:first-childh4,a:first-childh5,a:first-childh6{margin-top:0;padding-top:0;}h1p,h2p,h3p,h4p,h5p,h6p{margin-top:0;}lip.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;}h3.md-focus:before{width:auto;height:auto;color:rgb(50,9,212);background-color:#ff5d52;border:1pxsolid;border-radius:3px;position:absolute;left:-1.642857143rem;top:0.357142857rem;float:left;font-size:9px;padding-left:2px;padding-right:2px;vertical-align:bottom;font-weight:400;line-height:normal;}h4.md-focus:before{width:auto;height:auto;color:rgb(50,9,212);background-color:#ff5d52;border:1pxsolid;border-radius:3px;position:absolute;left:-1.642857143rem;top:0.357142857rem;float:left;font-size:9px;padding-left:2px;padding-right:2px;vertical-align:bottom;font-weight:400;line-height:normal;}h5.md-focus:before{width:auto;height:auto;color:rgb(50,9,212);background-color:#ff5d52;border:1pxsolid;border-radius:3px;position:absolute;left:-1.642857143rem;top:0.357142857rem;float:left;font-size:9px;padding-left:2px;padding-right:2px;vertical-align:bottom;font-weight:400;line-height:normal;}h6.md-focus:before{width:auto;height:auto;color:rgb(50,9,212);background-color:#ff5d52;border:1pxsolid;border-radius:3px;position:absolute;left:-1.642857143rem;top:0.357142857rem;float:left;font-size:9px;padding-left:2px;padding-right:2px;vertical-align:bottom;font-weight:400;line-height:normal;}注意:只有3-6级标题有效,1-2级别标题是没效果的额。
  • 效果展示

img

案例:h1-h6标题风格设置(边框+分割线版)-2022.9.11

  • 配置方法

img

css
h1,h2,h3,h4,h5,h6{position:relative;margin-top:1rem;margin-bottom:1rem;font-weight:bold;line-height:1.4;cursor:text;}h1:hovera.anchor,h2:hovera.anchor,h3:hovera.anchor,h4:hovera.anchor,h5:hovera.anchor,h6:hovera.anchor{text-decoration:none;}h1tt,h1code{font-size:inherit!important;}h2tt,h2code{font-size:inherit!important;}h3tt,h3code{font-size:inherit!important;}h4tt,h4code{font-size:inherit!important;}h5tt,h5code{font-size:inherit!important;}h6tt,h6code{font-size:inherit!important;}h2a,h3a{color:#34495e;}\#write h1{font-size:1.5rem;font-family:"华康手札体W5P";border-bottom:2pxsolidrgba(140,68,250,0.7);}\#write h1span{display:inline-block;font-weight:bold;background:rgba(140,68,250,0.7);color:blue;padding:3px10px1px;border-top-right-radius:3px;border-top-left-radius:3px;margin-right:3px;}\#write h1:after{display:inline-block;content:"";vertical-align:bottom;border-bottom:42pxsolid#C0C0C0;border-right:20pxsolidtransparent;}\#write h2{font-size:1.3rem;font-family:"华康手札体W5P";border-bottom:2pxsolidrgb(239,112,96);}\#write h2span{display:inline-block;font-weight:bold;background:rgb(239,112,96);color:blue;padding:3px10px1px;border-top-right-radius:3px;border-top-left-radius:3px;margin-right:3px;}\#write h2:after{display:inline-block;content:"";vertical-align:bottom;border-bottom:36pxsolid#C0C0C0;border-right:20pxsolidtransparent;}\#write h3{font-size:1.1rem;font-family:"华康手札体W5P";border-bottom:2pxsolidrgba(2,171,107,0.7);}\#write h3span{display:inline-block;font-weight:bold;background:rgba(2,171,107,0.7);color:blue;padding:3px10px1px;border-top-right-radius:3px;border-top-left-radius:3px;margin-right:3px;}\#write h3:after{display:inline-block;content:"";vertical-align:bottom;border-bottom:30pxsolid#C0C0C0;border-right:20pxsolidtransparent;}\#write h4{font-size:1rem;font-family:"华康手札体W5P";border-bottom:2pxsolid#FCE6C9;}\#write h4span{display:inline-block;font-weight:bold;background:#FCE6C9;color:blue;padding:3px10px1px;border-top-right-radius:3px;border-top-left-radius:3px;margin-right:3px;}\#write h4:after{display:inline-block;content:"";vertical-align:bottom;border-bottom:27pxsolid#C0C0C0;border-right:20pxsolidtransparent;}\#write h5{font-size:0.9rem;font-family:"华康手札体W5P";border-bottom:2pxsolid#33A1C9;}\#write h5span{display:inline-block;font-weight:bold;background:#33A1C9;color:blue;padding:3px10px1px;border-top-right-radius:3px;border-top-left-radius:3px;margin-right:3px;}\#write h5:after{display:inline-block;content:"";vertical-align:bottom;border-bottom:26pxsolid#C0C0C0;border-right:20pxsolidtransparent;}\#write h6{font-size:0.8rem;font-family:"华康手札体W5P";border-bottom:2pxsolid#FFC0CB;}\#write h6span{display:inline-block;font-weight:bold;background:#FFC0CB;color:blue;padding:3px10px1px;border-top-right-radius:3px;border-top-left-radius:3px;margin-right:3px;}\#write h6:after{display:inline-block;content:"";vertical-align:bottom;border-bottom:25pxsolid#C0C0C0;border-right:20pxsolidtransparent;}
  • 效果展示

img

问题:能否定制无限级别的标题

  • 测试

这个在css里添加的h7,h8代码,typora里是无法识别的:

img

img

案例:这个绿色风格也不错的哦-2022.9.11

  • 来源配色2.css:

img

  • 配置代码
css
h1{font-size:28px;color:#1EA089;}

img

案例:这个蓝色风格也不错的哦-2022.9.12

  • 来源blue-plum.css:

img

img

  • 配置代码
css
h1{font-family:"华康手札体W5P";font-size:32px!important;text-align:center;display:block;color:var(--main-color-2);}h1:after{content:"";width:80px;height:2px;display:block;border-bottom:2pxsolidvar(--main-color-2);margin:-4pxauto0;}--main-color-2:#1677b3;
  • 效果展示

img

案例:这个绿色风格也不错的哦-2022.9.14

  • 来源cyan-moon.css:

img

img

css
h1{text-align:center;font-size:2.2rem;line-height:1.2;margin:2.8remauto2.2rem;color:var(--main-color-11);}--main-color-11:#0BABAB;

链接

案例:小图标

更改后效果如下:

image-20240516072730804

配置代码:

image-20240516073054564

css
#writea:not(.md-toc-inner) {color:magenta;border-bottom:1pxsolid#ffb143;text-decoration:none;transform:alllinear0.1s;}#writea:hover:not(.md-toc-inner) {color:#e46918;border-bottom:1pxsolid#e46918;transform:alllinear0.1s;}#writepa:not(.md-toc-inner)::before{content:url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http:color:#f68800;display:inline-block;width:1em;height:1em;margin-right:0.2em;vertical-align:sub;}#writesupa::before{content:none;}

案例:云朵风格

  • 配置方法

img

css
\#write a{color:Magenta;text-decoration:none;font-weight:600;padding:02px;text-decoration:none;border-bottom:1pxsolid#00BFFF;}\#write a:hover{color:#04BAFB;;text-decoration:none;}\#write a:before{content:"☁";text-align:center;line-height:1.6rem;display:inline-block;margin-right:0.2em;width:1.6rem;height:1.6rem;color:var(--h-sign);}
  • 效果展示

img

img

案例:云朵+按钮风格

哈哈,这个风格还是不推荐了,很丑的,如果链接出现在了正文后。

  • 配置方法

img

css
[md-inline] a{background-color:#dbe2ef;color:Magenta;text-decoration:none;font-weight:600;padding:08px;padding-top:5px;padding-bottom:5px;box-shadow:4px4px4px#aaa;blur:2px;border-radius:20px;}\#write a:hover{color:#04BAFB;;text-decoration:none;}\#write a:before{content:"☁";text-align:center;line-height:1.6rem;display:inline-block;margin-right:0.2em;width:1.6rem;height:1.6rem;color:var(--h-sign);}
  • 效果展示

imgimg

背景

示例:选中文本背景颜色修改

  • 配置方法
css
div::selection{background:var(--main-color);color:white;}div::-moz-selection{background:var(--main-color);color:white;}div::-webkit-selection{background:var(--main-color);color:white;}blockquote::selection{background:var(--main-color);color:white;}blockquote::-moz-selection{background:var(--main-color);color:white;}blockquote::-webkit-selection{background:var(--main-color);color:white;}p::selection{background:var(--main-color);color:white;}p::-moz-selection{background:var(--main-color);color:white;}p::-webkit-selection{background:var(--main-color);color:white;}label::selection{background:var(--main-color);color:white;}label::-moz-selection{background:var(--main-color);color:white;}label::-webkit-selection{background:var(--main-color);color:white;}span::selection{background:var(--main-color);color:white;}span::-moz-selection{background:var(--main-color);color:white;}span::-webkit-selection{background:var(--main-color);color:white;}h1::selection{background:var(--main-color);color:white;}h1::-moz-selection{background:var(--main-color);color:white;}h1::-webkit-selection{background:var(--main-color);color:white;}h2::selection{background:var(--main-color);color:white;}h2::-moz-selection{background:var(--main-color);color:white;}h2::-webkit-selection{background:var(--main-color);color:white;}h3::selection{background:var(--main-color);color:white;}h3::-moz-selection{background:var(--main-color);color:white;}h3::-webkit-selection{background:var(--main-color);color:white;}h4::selection{background:var(--main-color);color:white;}h4::-moz-selection{background:var(--main-color);color:white;}h4::-webkit-selection{background:var(--main-color);color:white;}h5::selection{background:var(--main-color);color:white;}h5::-moz-selection{background:var(--main-color);color:white;}h5::-webkit-selection{background:var(--main-color);color:white;}code::selection{background:var(--main-color);color:white;}code::-moz-selection{background:var(--main-color);color:white;}code::-webkit-selection{background:var(--main-color);color:white;}
  • 效果展示

img

示例:设置空白typora文档时的背景颜色(骚里骚气哈哈)

  • 配置方法

img

css
\#write >p:first-child:not(:only-child)::before,#write>p:only-child::before{background:url("./image/blue-plum.png") no-repeat55%90%transparent;background-size:cover;}\#write >p:first-child:empty{position:static;}\#write >p:only-child:empty::before{content:'';display:block;position:absolute;top:0;left:0;right:0;bottom:0;background:url("./image/blue-plum.png") no-repeat45%90%transparent;background-size:cover;-webkit-background-size:cover;-moz-background-size:cover;-o-background-size:cover;}
  • 效果展示

打开一个空白文档是,就有花花背景出现了哈哈。

当输入内容时,花花就消失了。

img

img

示例:设置搜索框字体及背景颜色

  • 配置方法

img

css
\#md-searchpanelinput{height:26px;background:inherit;color:red;background-color:#ff0;border-radius:0;width:100%;font-size:18px;}
  • 效果展示

img

示例:设备背景图片

方法1:抠图方法

  • 修改方法

以这张图片为背景:

img

利用wps把自己想要的图片背景给去掉:

img

然后用wps打开这个被抠过图的照片,然后打开上面那张green照片作为背景,然后调整抠过图的照片的大小,进行截图即可。

具体照片如下:

img

代码如下:

img

css
background:url(./image/高圆圆1.png);background-size:cover;background-repeat:no-repeat;background-attachment:scroll;
  • 效果展示

img

方法2:护眼绿配置方法

  • 配置方法

img

css
:root{--side-bar-bg-color:#c7e6c8;--control-text-color:#777;--background-color:#c7edcc;background:url('./bg_image/v-34.png') repeat}\#typora-sidebar{background:url('./bg_image/v-35.png') repeat}

img

细节:

css
:root{--side-bar-bg-color:#c7e6c8;--control-text-color:#777;\#background-color:#c7edcc;background:url('./bg_image/v-34.png') repeat}

img

img

是600*600大小的图片:

img

  • 效果如下

img

示例:打开空白笔记展示笔记封面 设置

  • 配置方法
css
\#write >p:first-child:not(:only-child)::before,#write>p:only-child::before{background:url("./image/blue-plum.png") no-repeat55%90%transparent;background-size:cover;}\#write >p:first-child:empty{position:static;}\#write >p:only-child:empty::before{content:'';display:block;position:absolute;top:0;left:0;right:0;bottom:0;background:url("./image/blue-plum.png") no-repeat45%90%transparent;background-size:cover;-webkit-background-size:cover;-moz-background-size:cover;-o-background-size:cover;}

img

  • 效果展示

img

或者是其他图片:

img

css
#write>p:first-child:not(:only-child)::before,#write>p:only-child::before{background:url("./image/lover.png") no-repeat55%90%transparent;background-size:cover;}#write>p:first-child:empty{position:static;}#write>p:only-child:empty::before{content:'';display:block;position:absolute;top:0;left:0;right:0;bottom:0;background:url("./image/lover.png") no-repeat45%90%transparent;background-size:cover;-webkit-background-size:cover;-moz-background-size:cover;-o-background-size:cover;}

img

root字段

  • 配置方法
css
:root{--text-color:#666;--bg-color:#fff;--code-block-bg-color:#4d4d4d;--side-bar-bg-color:#fdf6f5;--window-border:1pxsolid#555;--active-file-bg-color:#fff;--active-file-text-color:#666;--item-hover-text-color:#666;--control-text-color:#777;}

img

  • 效果展示

img

img

css
:root{--side-bar-bg-color:rgba(231,153,176,0.5);--window-border:2pxsolid#E799B0;--main-color:rgba(128,30,255,1);--shadow-color:rgb(178,80,255);--transplate-color:rgba(128,30,255,0.1);--dark-color:rgb(70,18,137);--light-color:rgb(248,242,255);--font-color:rgb(12,12,12);--base-font:"Glow Sans","Microsoft YaHei",serif;--title-font:"Roboto Slab","Times",serif;--blockquote-font:"Times","Roboto Slab",serif;--blockquote-color:rgba(117,117,117,0.9);--monospace:"Cascadia code","Courier New",monospace;--quote-title-font-size:0.9em;--quote-tag-font-size:1.1em;--sidebar-font-color:black;--main-panel-font-color:black;}

vscode里,ctrl单机这个变量后,就可以看到那些地方用到了这个变量的:

img

小图标

常见图标:

image-20240518085831437

image-20240518102934340

分割线

  • 配置方法:

img

css
hr{margin-top:20px;margin-bottom:20px;border:0;border-top-color:rgb(66,165,245);border-top-style:solid;border-top-width:1px;border-right-color:initial;border-right-style:initial;border-right-width:0px;border-bottom-color:initial;border-bottom-style:initial;border-bottom-width:0px;border-left-color:initial;border-left-style:initial;border-left-width:0px;border-image-source:initial;border-image-slice:initial;border-image-width:initial;border-image-outset:initial;border-image-repeat:initial;border-top:1pxsolid#42a5f5;border-top-width:1px;border-top-style:solid;border-top-color:rgb(66,165,245);}
  • 效果展示

img

yaml

  • 配置方法

img

css
\#write pre.md-meta-block{font-family:var(--monospace-font);font-size:1rem;text-align:left;color:var(--code-color);background-color:var(--code-background-color);padding:1rem;border:0;border-radius:20px20px20px20px;margin-top:0!important;}
  • 效果展示

img

结尾

  • 配置方法

img

css
\#write:after{font-size:18px;font-family:'optima regular';content:"End(双向奔赴,不离不弃)";color:var(--main-color-4);font-weight:bold;text-align:center;margin-top:3rem;display:block;}
  • 效果展示

img

body字段

  • 配置方法
css
html{font-size:18px;}body{font-family:"华康手札体W5P",'Microsoft YaHei',"SimSun","Clear Sans","Helvetica Neue",Helvetica,Arial,sans-serif;color:rgb(51,51,51);line-height:1.6;}![img](D:\BaiduSyncdisk\LocalImgs\1664791724870-8ff0aa68-94f6-43bd-8b0f-20332ba4d265.png)
  • 效果展示

img

书写区域宽度

案例1:阴影效果

  • 配置方法

img

css
\#write{max-width:960px;margin-top:30px;margin-bottom:30px;padding:100px60px;border-radius:5px;-o-box-shadow:010px10px#333333;-webkit-box-shadow:010px10px#333333;-moz-box-shadow:010px10px#333333;box-shadow:0px50px100px#333333;}\#write >ul:first-child,\#write >ol:first-child{margin-top:30px;}
  • 效果展示

img

案例2:全屏

  • 配置方法

img

css
\#write{max-width:96%;margin-top:30px;margin-bottom:30px;padding:10px10px;border-radius:5px;}
  • 效果展示

img

案例3:有小的边框

  • 配置方法

img

css
\#write{max-width:96%;margin-top:30px;margin-bottom:30px;padding:10px10px;border-radius:5px;-o-box-shadow:010px10pxpink;-webkit-box-shadow:010px10pxpink;-moz-box-shadow:010px10pxpink;box-shadow:050px100pxpink;}
  • 效果展示

img

img

引用

案例:绿色

  • 配置方法

img

css
blockquote{border-left:4pxsolid#42b983;padding:10px15px;color:#777;background-color:rgba(66,185,131,.1);}
  • 效果展示

img

案例:月亮

  • 配置方法

img

css
blockquotep:first-of-type::before{content:"☽";position:relative;font-size:3em;padding:0.5rem;color:#0dc8c4;font-family:Arial,serif;line-height:0.7em;font-weight:700;}blockquote{border:2pxdouble#0cb4b0;border-radius:6px;margin:3remauto;padding:10px15px26px;color:black!important;background-color:#FFEFD5;font-family:'HelveticaN',Arial,"kaiti","pingfangSC light","microsoft yahei"!important;}
  • 效果展示

img

案例:红-黄

  • 配置方法

img

css
blockquote{border-left:4pxsolid#CD00CD;padding:10px15px;color:var(--color-black);background-color:#DEB887;border-radius:0.5em;}
  • 效果展示

img

案例:小花花

  • 配置方法

img

css
blockquotep:first-of-type::before{display:inline;content:"❀";position:relative;font-size:2rem;padding:0.3rem;color:var(--blockquote-border-color);font-family:Arial;}blockquote{border-left:4pxsolid#CD00CD;padding:10px15px;color:var(--color-black);background-color:#DEB887;border-radius:0.5em;}blockquotestrong{color:#FA6A82!important;}
  • 效果展示

img

流程图

案例:紫色

  • 配置方法

img

css
--mermaid-theme:night;--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;--mermaid-sequence-numbers:on;--mermaid-flowchart-curve:linear ;--mermaid--gantt-left-padding:75;
  • 效果展示

img

字体

Typora里好看的中文字体推荐下(gpt回答-2023.8.24)

Typora里好看的中文字体推荐下

在 Typora 中选择适合的中文字体可以提升阅读体验和视觉效果。以下是几款在 Typora 中常用且美观的中文字体推荐:

  1. 宋体:比如宋体、仿宋等。作为中文传统明朝体的代表,较为正式和经典。
  2. 黑体:比如方正黑体、思源黑体等。黑体字形端正,粗细均匀,适合用于标题和强调的文字。
  3. 微软雅黑:作为一款无衬线字体,简洁清晰,适合用于屏幕显示和阅读。
  4. 华文中宋:华文系列中文字体之一,结合了宋体和新细明体的特点,有一定的书法气息。
  5. Work Sans(思源黑体的变体):作为一种开源字体,Work Sans 在 Typora 中也有很好的表现,具有现代感。

您可以在 Typora 的设置选项中找到字体设置,根据喜好尝试不同的中文字体,并根据字体大小和行距进行适当调整,以获得更好的排版效果。

希望这些推荐对您有所帮助,请随时提问,我将竭力为您服务!

字体还可以这样使用

img

imgimg

案例:设置正文字体

  • 配置方法:

img

css
html,body,content{font-size:18px;font-family:"霞鹜文楷","华康手札体W5P",'Microsoft YaHei',"SimSun","Clear Sans","Helvetica Neue",Helvetica,Arial,sans-serif;color:rgb(51,51,51);line-height:1.6;}
  • 效果展示

img

案例:设置加粗字体、倾斜字体颜色

  • 配置方法

img

css
pstrong{color:#1EA089;}pem{color:#FDB22F;font-weight:bold;font-style:normal;}
  • 效果展示

img

高亮背景和字体颜色

  • 配置方法

img

img

css
mark{background:yellow;color:#f22f27;font-weight:bold;border-bottom:0pxsolid#ffffff;padding:0.0px;margin:00px;}
  • 效果展示

img

任务列表

案例1:紫色【荐】

  • 配置方法

img

css
.md-task-list-item>input{margin-left:-1.3em;}.md-task-list-item>input{margin-left:-1.3em;}.md-task-list-item:hover>input:before,input[type='checkbox']:hover:before{opacity:1;transition:0.3s;background-color:var(--shadow-color);}.task-list-iteminput::before{content:"";display:inline-block;border-radius:.3em;vertical-align:middle;border:1.2pxsolidvar(--main-color);background-color:#ffffff;width:1.1rem;height:1.1rem;margin-left:-0.1rem;margin-right:0.1rem;margin-top:-0.68rem;}.task-list-iteminput:checked::before{padding-left:0.125em;content:'✔';color:white;background-color:var(--main-color);font-size:0.8rem;line-height:0.95rem;margin-top:-0.68rem;transition:background-color 200msease-in-out;}\#write .md-task-list-item.task-list-done>p{color:#808080;text-decoration:line-through;}
  • 效果展示

img

案例:默认github主题

  • 配置方法

img

css
.md-task-list-item>input{margin-left:-1.3em;}
  • 效果展示

img

css语法

import语法

img

img

img

img

gpt回答

2023.8.24

请给我编辑一款优秀的typora主题!

很抱歉,作为文本聊天 AI,我无法直接为你生成和编辑主题文件。但是,我可以向你提供一些指导,帮助你自己设计和编辑 Typora 主题。

  1. 选择颜色方案:选择一种适合你审美和写作环境的颜色方案,可以是明亮的、深色的或者中性的。考虑使用颜色搭配工具来找到搭配合适的颜色。
  2. 设计字体样式:选择合适的字体和字号,确保显示清晰、易读。可以使用谷歌字体等免费字体资源,定义标题、段落和代码的字体样式。
  3. 定义排版规则:通过 CSS 修改 Typora 的默认样式,包括调整标题的大小、行高、段落间距和代码块的样式等。可以参考 Typora 官方文档中的样式指南。
  4. 添加自定义样式:通过 CSS 修改其他元素的样式,例如列表、引用、表格等。可以为这些元素添加背景色、边框样式和阴影效果,使其更加醒目。
  5. 测试和调整:在编辑主题的过程中,记得不断地在 Typora 中测试你的修改,并根据实际效果进行调整。确保字体清晰可读,元素排版合理,避免过于花哨或干扰写作的样式。

以上是一些基本的设计步骤,希望能对你编辑一款优秀的 Typora 主题有所帮助。记得参考 Typora 的官方文档和在社区中学习,以获得更详细和专业的指导。