在降价表中设置特定单元格的背景颜色

luc*_*928 19 markdown

我有一个降价表如下:

| 1 | 2 | 3 |
|---|---|---|
| 4 | 5 | 6 |
| 7 | 8 | 9 |
Run Code Online (Sandbox Code Playgroud)

我希望将特定单元格的背景颜色设置为红色,例如单元格8.我发现一些讨论的论坛使用HTML语法来设置字体颜色,但没有发现任何人都可以将整个单元格背景颜色设置为红色.

klm*_*lml 16

背景色是风格的一部分.Markdown仅适用于内容和结构.

但是你可以使用css选择器

  • 如果你可以使用css3: td:nth-child(n)
  • 使用css2:td + td并再次覆盖它td + td + td

两个版本都带有你的例子


小智 8

我在这里找到了一个适用于 Microsoft Visual Studio Code 预览的 Markdown 表格样式示例。

下面的例子在这里给出了这个结果

## Table Styling in Markdown

<style>
.heatMap {
    width: 70%;
    text-align: center;
}
.heatMap th {
background: grey;
word-wrap: break-word;
text-align: center;
}
.heatMap tr:nth-child(1) { background: red; }
.heatMap tr:nth-child(2) { background: orange; }
.heatMap tr:nth-child(3) { background: green; }
</style>

<div class="heatMap">

| Everything | in this table | is Centered |  and the table will only take up 70% of the screen width  | 
| -- | -- | -- | -- |
| This | is | a | Red Row |
| This | is | an | Orange Row |
| This | is | a | Green Row |

</div>
Run Code Online (Sandbox Code Playgroud)

  • 请注意,这不适用于 github wiki,它(至少到目前为止)不允许自定义样式 https://github.com/gollum/gollum/issues/618 (2认同)