是否可以将表格居中在Markdown文件中?

问题描述 投票:23回答:4

我有一张桌子:

    | This | Is | A | Table |
    | :--- | -- | - | ----: |
    | foo  | ba | r | elbaT |

我希望表格显示在我的Markdown文件的中心,而不是左对齐。我不是要对齐文本,而是要对齐整个表格本身。我需要依靠HTML / CSS来实现我想要的吗?

这是给Apiary.io项目的。

markdown github-flavored-markdown apiblueprint apiary.io
4个回答
31
投票

如果使用标准文档,请像这样使用<center>标签。

蓝图

FORMAT: 1A
HOST: http://www.google.com

# Tables
Notes API is a *short texts saving* service similar to its physical paper presence on your table.

<center>

| Tables   |      Are      |  Cool |
|----------|:-------------:|------:|
| col 1 is |  left-aligned | $1600 |
| col 2 is |    centered   |   $12 |
| col 3 is | right-aligned |    $1 |

</center>

# Group Notes

(...)

预览

“”


如果使用'New Documentation',则无法将表格居中(由于表格占据了列的整个宽度)

预览

“”


8
投票

是。您可以在API蓝图中有GFM表–检查http://docs.tables.apiary.io以获取以下蓝图源的渲染版本。

FORMAT: 1A

# Tables API 
Note: Tables can be handcrafted or generated at <http://www.tablesgenerator.com/markdown_tables>.

## Table 1
**Discussion option 1**

| Tables   |      Are      |  Cool |
|----------|:-------------:|------:|
| col 1 is |  left-aligned | $1600 |
| col 2 is |    centered   |   $12 |
| col 3 is | right-aligned |    $1 |

# Message [/pages]
## Create a Message [POST]

### Table 2
**Discussion option 2**

| Tables   |      Are      |  Cool |
|----------|:-------------:|------:|
| col 1 is |  left-aligned | $1600 |
| col 2 is |    centered   |   $12 |
| col 3 is | right-aligned |    $1 |

+ Request (application/json)

    ## Table 3
    **Discussion option 3**

    | Tables   |      Are      |  Cool |
    |----------|:-------------:|------:|
    | col 1 is |  left-aligned | $1600 |
    | col 2 is |    centered   |   $12 |
    | col 3 is | right-aligned |    $1 |

    + Headers

            Authorization:Bearer tokenString

    + Body

            { ... }

+ Response 201

6
投票

My solution detailed by Gaffney in an Apiary.io issue comment

[基本上,我在apiary.apib HTML块中添加自定义样式表和脚本,以使用HTML设置页面样式,而不是标记Markdowndiale ct不是CSS。

"How to Center Anything in CSS"


0
投票

很简单。如您所知,“ |-|”用于指示表格,“:”用于指示文本对齐。如果输入|:-|,则它是右对齐的文本列。如果输入|-:|是左对齐文本,如果输入|:-:|是居中对齐。

© www.soinside.com 2019 - 2024. All rights reserved.