【问题标题】:Is there a way to colspan a table header with GitHub flavored markdown?有没有办法用 GitHub 风格的降价来跨表标题?
【发布时间】:2018-07-03 06:23:23
【问题描述】:

HTML 允许使用colspan 跨多个列扩展表格的标题行:

<table>
  <tr><th colspan=2>Logical Operators</th></tr>
  <tr><td>&&</td><td>Logical and</td></tr>
  <tr><td>||</td><td>Logical or</td></tr>
  <tr><td>!</td><td>Logical not</td></tr>
  <tr><td>? :</td><td>Logical ternary</td></tr>
</table>

在 GitHub 上,当这个 HTML 在 readme.md 文件中呈现时,它看起来像这样:

...但是using markdown syntax to create a table,我不能跨列跨越表格的标题行,例如我只能拆分标题文本:

| Logical | Operators |
|:---:| --- |
| `&&` | Logical and |
| `\|\|` | Logical or |
| `!` | Logical not |
| `? :` | Logical ternary |

...在 GitHub 上渲染 GFM 表如下所示:

我尝试模拟this solution 在表的数据行中使用colspan,但我无法让它与标题行一起使用。有没有办法使用 GitHub 风格的 Markdown 将 GFM table's 标题行跨越多个列?

我已通过GH MD repo 向人们发布了这个问题。

【问题讨论】:

    标签: html-table github-flavored-markdown


    【解决方案1】:

    我这样做是为了生成一个包含 5 列的表,其中标题分别跨越 3 列和 2 列:

    <table>
    <tr>
    <td colspan=3>a  <td colspan=2>b
    <tr>
    <td colspan=1>col1 <td colspan=1>col2 <td colspan=1>col3<td colspan=1>col4 <td colspan=1>col5
    </table>
    

    我的两分钱。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-16
      • 1970-01-01
      • 1970-01-01
      • 2013-02-15
      • 1970-01-01
      • 2021-10-25
      相关资源
      最近更新 更多