首页 > 解决方案 > GitHub 风格的 Markdown:更改代码块的背景颜色

问题描述

我正在使用 GitHub Pages 制作一个网站,并希望显示具有白色背景的输出代码,而不是代码元素的默认灰色背景(但保留等宽字体)。

在我的index.md文件中,我尝试添加一个内联 HTML 块来处理这个问题,因为 GitHub 风格的 Markdown 不允许您更改代码元素的背景。我使用了以下代码:

<pre><span style="display:block; background-color:white"><code>## Constructed an OTU  table and other variables with the following settings:
## thresh_prevalence: 80
## thresh_abundance: 0.5
## thresh_NA: 5
## subj: subject_1
</code></span></pre>

但是输出没有白色背景。相反,它具有默认背景颜色:

在 GitHub 风格的 Markdown 版本中,样式似乎没有列入白名单。有没有办法在没有样式标签或完全没有 HTML 的情况下更改代码块的背景颜色?

标签: htmlcssmarkdowngithub-pagesgithub-flavored-markdown

解决方案


推荐阅读