vscode 修改默认 Markdown 预览样式

如何修改 vs code 默认的 Markdown 预览样式

vs code 预览 Markdown 文件的快捷键为 Ctrl + Shift + V.

其实在 vs code 中有默认的 Markdown 样式, 但是不一定是我们喜欢的.

/* 要在 Markdown 预览中使用的 CSS 样式表的 URL 或本地路径列表。相对路径被解释为相对于资源管理器中打开的文件夹。如果没有任何打开的文件夹,则会被解释为相对于 Markdown 文件的位置。所有的 "\" 需写为 "\\"。*/

"markdown.styles": [],

我们可以这样引用本地 css 文件

"markdown.styles": [ "file:///D:/Microsoft VS Code/vscode_markdown.css" ]

也可以引用第三方文件

"markdown.styles": [ "https://jasonm23.github.io/markdown-css-themes/foghorn.css" ]

比如, 我在 Google 搜索 vscode markdown css, 返回的结果如下
vscode markdown css
点进去看看那个是自己喜欢的, 把它复制到你本地的 vscode_markdown.css文件中, 你还可以继续按自己的想法修改.
我用的是下面的配置, 感觉还不错.

/**
* author: https://github.com/raycon/vscode-markdown-css
*/
body {
    -ms-text-size-adjust: 100%;
    -webkit-text-size-adjust: 100%;
    line-height: 1.5;
    color: #333;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
    font-size: 16px;
    line-height: 1.5;
    word-wrap: break-word;
}

.pl-c {
    color: #969896;
}

.pl-c1,
.pl-s .pl-v {
    color: #0086b3;
}

.pl-e,
.pl-en {
    color: #795da3;
}

.pl-smi,
.pl-s .pl-s1 {
    color: #333;
}

.pl-ent {
    color: #63a35c;
}

.pl-k {
    color: #a71d5d;
}

.pl-s,
.pl-pds,
.pl-s .pl-pse .pl-s1,
.pl-sr,
.pl-sr .pl-cce,
.pl-sr .pl-sre,
.pl-sr .pl-sra {
    color: #183691;
}

.pl-v {
    color: #ed6a43;
}

.pl-id {
    color: #b52a1d;
}

.pl-ii {
    color: #f8f8f8;
    background-color: #b52a1d;
}

.pl-sr .pl-cce {
    font-weight: bold;
    color: #63a35c;
}

.pl-ml {
    color: #693a17;
}

.pl-mh,
.pl-mh .pl-en,
.pl-ms {
    font-weight: bold;
    color: #1d3e81;
}

.pl-mq {
    color: #008080;
}

.pl-mi {
    font-style: italic;
    color: #333;
}

.pl-mb {
    font-weight: bold;
    color: #333;
}

.pl-md {
    color: #bd2c00;
    background-color: #ffecec;
}

.pl-mi1 {
    color: #55a532;
    background-color: #eaffea;
}

.pl-mdr {
    font-weight: bold;
    color: #795da3;
}

.pl-mo {
    color: #1d3e81;
}

.octicon {
    display: inline-block;
    vertical-align: text-top;
    fill: currentColor;
}

a {
    background-color: transparent;
    -webkit-text-decoration-skip: objects;
}

a:active,
a:hover {
    outline-width: 0;
}

strong {
    font-weight: inherit;
}

strong {
    font-weight: bolder;
}

h1 {
    font-size: 2em;
    margin: 0.67em 0;
}

img {
    border-style: none;
}

svg:not(:root) {
    overflow: hidden;
}

code,
kbd,
pre {
    font-family: monospace, monospace;
    font-size: 1em;
}

hr {
    box-sizing: content-box;
    height: 0;
    overflow: visible;
}

input {
    font: inherit;
    margin: 0;
}

input {
    overflow: visible;
}

[type="checkbox"] {
    box-sizing: border-box;
    padding: 0;
}

* {
    box-sizing: border-box;
}

input {
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
}

a {
    color: #4078c0;
    text-decoration: none;
}

a:hover,
a:active {
    text-decoration: underline;
}

strong {
    font-weight: 600;
}

hr {
    height: 0;
    margin: 15px 0;
    overflow: hidden;
    background: transparent;
    border: 0;
    border-bottom: 1px solid #ddd;
}

hr::before {
    display: table;
    content: "";
}

hr::after {
    display: table;
    clear: both;
    content: "";
}

table {
    border-spacing: 0;
    border-collapse: collapse;
}

td,
th {
    padding: 0;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    margin-top: 0;
    margin-bottom: 0;
}

h1 {
    font-size: 32px;
    font-weight: 600;
}

h2 {
    font-size: 24px;
    font-weight: 600;
}

h3 {
    font-size: 20px;
    font-weight: 600;
}

h4 {
    font-size: 16px;
    font-weight: 600;
}

h5 {
    font-size: 14px;
    font-weight: 600;
}

h6 {
    font-size: 12px;
    font-weight: 600;
}

p {
    margin-top: 0;
    margin-bottom: 10px;
}

blockquote {
    margin: 0;
}

ul,
ol {
    padding-left: 0;
    margin-top: 0;
    margin-bottom: 0;
}

ol ol,
ul ol {
    list-style-type: lower-roman;
}

ul ul ol,
ul ol ol,
ol ul ol,
ol ol ol {
    list-style-type: lower-alpha;
}

dd {
    margin-left: 0;
}

code {
    font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace;
    font-size: 12px;
}

pre {
    margin-top: 0;
    margin-bottom: 0;
    font: 12px Consolas, "Liberation Mono", Menlo, Courier, monospace;
}

.octicon {
    vertical-align: text-bottom;
}

input {
    -webkit-font-feature-settings: "liga" 0;
    font-feature-settings: "liga" 0;
}

.markdown-body::before {
    display: table;
    content: "";
}

.markdown-body::after {
    display: table;
    clear: both;
    content: "";
}

.markdown-body>*:first-child {
    margin-top: 0 !important;
}

.markdown-body>*:last-child {
    margin-bottom: 0 !important;
}

a:not([href]) {
    color: inherit;
    text-decoration: none;
}

.anchor {
    float: left;
    padding-right: 4px;
    margin-left: -20px;
    line-height: 1;
}

.anchor:focus {
    outline: none;
}

p,
blockquote,
ul,
ol,
dl,
table,
pre {
    margin-top: 0;
    margin-bottom: 16px;
}

hr {
    height: 0.25em;
    padding: 0;
    margin: 24px 0;
    background-color: #e7e7e7;
    border: 0;
}

blockquote {
    padding: 0 1em;
    color: #777;
    border-left: 0.25em solid #ddd;
}

blockquote>:first-child {
    margin-top: 0;
}

blockquote>:last-child {
    margin-bottom: 0;
}

kbd {
    display: inline-block;
    padding: 3px 5px;
    font-size: 11px;
    line-height: 10px;
    color: #555;
    vertical-align: middle;
    background-color: #fcfcfc;
    border: solid 1px #ccc;
    border-bottom-color: #bbb;
    border-radius: 3px;
    box-shadow: inset 0 -1px 0 #bbb;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    margin-top: 24px;
    margin-bottom: 16px;
    font-weight: 600;
    line-height: 1.25;
}

h1 .octicon-link,
h2 .octicon-link,
h3 .octicon-link,
h4 .octicon-link,
h5 .octicon-link,
h6 .octicon-link {
    color: #000;
    vertical-align: middle;
    visibility: hidden;
}

h1:hover .anchor,
h2:hover .anchor,
h3:hover .anchor,
h4:hover .anchor,
h5:hover .anchor,
h6:hover .anchor {
    text-decoration: none;
}

h1:hover .anchor .octicon-link,
h2:hover .anchor .octicon-link,
h3:hover .anchor .octicon-link,
h4:hover .anchor .octicon-link,
h5:hover .anchor .octicon-link,
h6:hover .anchor .octicon-link {
    visibility: visible;
}

h1 {
    padding-bottom: 0.3em;
    font-size: 2em;
    border-bottom: 1px solid #eee;
}

h2 {
    padding-bottom: 0.3em;
    font-size: 1.5em;
    border-bottom: 1px solid #eee;
}

h3 {
    font-size: 1.25em;
}

h4 {
    font-size: 1em;
}

h5 {
    font-size: 0.875em;
}

h6 {
    font-size: 0.85em;
    color: #777;
}

ul,
ol {
    padding-left: 2em;
}

ul ul,
ul ol,
ol ol,
ol ul {
    margin-top: 0;
    margin-bottom: 0;
}

li>p {
    margin-top: 16px;
}

li+li {
    margin-top: 0.25em;
}

dl {
    padding: 0;
}

dl dt {
    padding: 0;
    margin-top: 16px;
    font-size: 1em;
    font-style: italic;
    font-weight: bold;
}

dl dd {
    padding: 0 16px;
    margin-bottom: 16px;
}

table {
    display: block;
    width: 100%;
    overflow: auto;
}

table th {
    font-weight: bold;
}

table th,
table td {
    padding: 6px 13px;
    border: 1px solid #ddd;
}

table tr {
    background-color: #fff;
    border-top: 1px solid #ccc;
}

table tr:nth-child(2n) {
    background-color: #f8f8f8;
}

img {
    max-width: 100%;
    box-sizing: content-box;
    background-color: #fff;
}

code {
    padding: 0;
    padding-top: 0.2em;
    padding-bottom: 0.2em;
    margin: 0;
    font-size: 85%;
    background-color: rgba(0, 0, 0, 0.04);
    border-radius: 3px;
}

code::before,
code::after {
    letter-spacing: -0.2em;
    content: "\00a0";
}

pre {
    word-wrap: normal;
}

pre>code {
    padding: 0;
    margin: 0;
    font-size: 100%;
    word-break: normal;
    white-space: pre;
    background: transparent;
    border: 0;
}

.highlight {
    margin-bottom: 16px;
}

.highlight pre {
    margin-bottom: 0;
    word-break: normal;
}

.highlight pre,
pre {
    padding: 16px;
    overflow: auto;
    font-size: 85%;
    line-height: 1.45;
    background-color: #f7f7f7;
    border-radius: 3px;
}

pre code {
    display: inline;
    max-width: auto;
    padding: 0;
    margin: 0;
    overflow: visible;
    line-height: inherit;
    word-wrap: normal;
    background-color: transparent;
    border: 0;
}

pre code::before,
pre code::after {
    content: normal;
}

.pl-0 {
    padding-left: 0 !important;
}

.pl-1 {
    padding-left: 3px !important;
}

.pl-2 {
    padding-left: 6px !important;
}

.pl-3 {
    padding-left: 12px !important;
}

.pl-4 {
    padding-left: 24px !important;
}

.pl-5 {
    padding-left: 36px !important;
}

.pl-6 {
    padding-left: 48px !important;
}

.full-commit .btn-outline:not(:disabled):hover {
    color: #4078c0;
    border: 1px solid #4078c0;
}

kbd {
    display: inline-block;
    padding: 3px 5px;
    font: 11px Consolas, "Liberation Mono", Menlo, Courier, monospace;
    line-height: 10px;
    color: #555;
    vertical-align: middle;
    background-color: #fcfcfc;
    border: solid 1px #ccc;
    border-bottom-color: #bbb;
    border-radius: 3px;
    box-shadow: inset 0 -1px 0 #bbb;
}

:checked+.radio-label {
    position: relative;
    z-index: 1;
    border-color: #4078c0;
}

.task-list-item {
    list-style-type: none;
}

.task-list-item+.task-list-item {
    margin-top: 3px;
}

.task-list-item input {
    margin: 0 0.2em 0.25em -1.6em;
    vertical-align: middle;
}

hr {
    border-bottom-color: #eee;
}


/** Theming **/

body {
    color: #333;
    background: white;
    padding: 0 25px;
}

.vscode-light,
.vscode-light pre code {
    color: #333;
}

.vscode-dark,
.vscode-dark pre code {
    color: #333;
}

.vscode-high-contrast,
.vscode-high-contrast pre code {
    color: #333;
}

.vscode-light code {
    color: #333;
}

.vscode-dark code {
    color: #333;
}

.vscode-light pre:not(.hljs),
.vscode-light code>div {
    background-color: #F6F8FA;
}

.vscode-dark pre:not(.hljs),
.vscode-dark code>div {
    background-color: #F6F8FA;
}

.vscode-high-contrast pre:not(.hljs),
.vscode-high-contrast code>div {
    background-color: #F6F8FA;
}

.vscode-high-contrast h1 {
    border-color: transparent;
}

.vscode-light table>thead>tr>th {
    border-color: #EAECEF;
}

.vscode-dark table>thead>tr>th {
    border-color: #EAECEF;
}

.vscode-light h1,
.vscode-light hr,
.vscode-light table>tbody>tr+tr>td {
    border-color: #EAECEF;
}

.vscode-dark h1,
.vscode-dark hr,
.vscode-dark table>tbody>tr+tr>td {
    border-color: #EAECEF;
}

.vscode-light blockquote,
.vscode-dark blockquote {
    padding: 0 1em;
    color: #777;
    border-left: 0.25em solid #ddd;
    background: transparent;
}

.vscode-high-contrast blockquote {
    padding: 0 1em;
    color: #777;
    border-left: 0.25em solid #ddd;
    background: transparent;
}
/*Contact GitHub API Training Shop Blog About
© 2017 GitHub, Inc. Terms Privacy Security Status Help*/
  • 4
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 6
    评论
### 回答1: 好的,以下是在VSCode中配置Markdown环境的步骤: 1. 在VSCode中安装Markdown扩展,可在左侧的“扩展”面板中搜索“markdown”并安装。 2. 安装Markdown渲染器,比如说“markdown-it”或“marked”。可以使用npm命令来安装,比如:npm install marked。 3. 在VSCode中打开Markdown文件后,按下“Ctrl+Shift+V”(或者通过查看菜单选择“预览”),即可打开Markdown渲染预览。 4. 可以在VSCode的用户设置中进行Markdown相关配置,如更改预览样式、更改默认Markdown渲染器等。可通过“文件”-“首选项”-“设置”打开设置面板,在搜索框中输入“markdown”来查找相关设置。 希望这些步骤对你有所帮助! ### 回答2: Visual Studio Code(简称VSCode)是一个轻量级的代码编辑器,同时也是一个开发工具。它不仅支持各种编程语言的编写和调试,还可以配置markdown环境来编辑和预览markdown文件。这里简单介绍一下如何配置VSCodemarkdown环境。 1. 安装VSCode 首先需要在官网下载VSCode,并安装完成。 2. 安装markdown插件 在VSCode的“扩展”面板中搜索“markdown”,选择一个比较好的插件进行安装,比如“markdown all in one”或者“Markdown Preview Enhanced”。 3. 安装markdown渲染器 安装markdown渲染器是为了在VSCode中能够直接预览markdown文件的效果。常见的markdown渲染器有两种:markdown-it和marked。推荐使用markdown-it。安装方法如下: - 打开终端,输入命令:npm install markdown-it -g, 回车安装markdown渲染器。 - 在VSCode中打开一个markdown文件,使用“Ctrl + Shift + P”打开命令面板;输入“open user settings”,打开用户设置面板。 - 在设置面板中,添加一个markdown.preview的设置,将它的值设置markdown-it: "markdown.preview": "markdown-it". 4. 配置markdown编辑器 在VSCode设置中,可以根据自己的习惯配置markdown编辑器的默认样式、字体、字号等。 - 打开一个markdown文件,使用“Ctrl + Shift + P”打开命令面板;输入“show markdown preview”,打开markdown预览。 - 在预览窗口中,使用“Ctrl + Shift + P”打开命令面板;输入“Markdown Preview Enhanced: Customize Css”,进入CSS配置界面,可以自定义markdown样式等。 至此,已经完成了VSCodemarkdown环境的配置。在自己的项目中进行markdown文档编写时,可以使用这个环境,方便编辑和预览。 ### 回答3: VSCode是一款支持多种语言的开源编辑器,支持markdown语言,并且其自带的markdown扩展确保了完美的语法高亮与代码块样式化。在进行markdown编辑时,VSCode可以方便的预览Markdown文件,并且支持Markdown文件的导入和导出。 下面详细介绍VSCode如何配置Markdown环境: 1. 安装VSCode 访问VSCode官网并下载最新版的VSCode,安装完成后打开VSCode。 2. 安装Markdown扩展 在VSCode界面的左侧菜单中点击『扩展』,然后在搜索栏中输入“Markdown”,点击搜索出的结果,并点击『安装』。 3. 配置Markdown预览样式 打开一个Markdown文件,在右上角找到“打开预览”按钮,点击即可在VSCode预览Markdown文件。但是默认样式可能不够美观,可以通过扩展或者修改配置文件的方式进行样式配置。 一种方式是使用“markdown-preview-enhanced”扩展,这个扩展可以帮助我们设置Markdown预览页面的主题,字体等细节配置。同样需要在『扩展』中搜索并安装这个扩展。 另一种方式是直接修改VSCode的用户设置,打开设置文件,搜索“markdown”选项。在这里可以选择使用GitHb Flavored Markdown,也可以自定义CSS样式等。 4. 配置Markdown文件导出 在markdown预览页面,点击“打开预览资源管理器”,即可看到Markdown文件的导出格式和选项。在这里可以选择导出HTML文件或者PDF文件,设置页面方向,页眉页脚等。 5. 其他 除了以上配置,VSCode还支持插入表格、公式等高级Markdown语法,通过快捷键Ctrl+Shift+v可以粘贴富文本,VSCode还支持Markdown文本转HTML、LaTeX、PDF等格式。 综上,VSCode是一款非常强大的Markdown编辑器,通过以上配置和设置,可以极大提高我们的Markdown编辑效率,为我们的工作和学习带来帮助。
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值