Hes*_*sam 21 markdown github readme
我想在readme.md文件中显示一个表.我读了GitHub Flavored Markdown并按照它说的做了.所以这是我的表:
| Attempt | #1 | #2 | #3 | #4 | #5 | #6 | #7 | #8 | #9 | #10 | #11 | #12 |
| :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: |
| Seconds | 301 | 283 | 290 | 286 | 289 | 285 | 287 | 287 | 272 | 276 | 269 | 254 |
Run Code Online (Sandbox Code Playgroud)
但是,我没有看到任何表格和结果如下:
Spe*_*ell 28
您需要再次查看文档.你可以看到这个备忘单
在您的情况下,您需要制作第二行,如下例所示:
Attempt | #1 | #2 | #3 | #4 | #5 | #6 | #7 | #8 | #9 | #10 | #11
--- | --- | --- | --- |--- |--- |--- |--- |--- |--- |--- |---
Seconds | 301 | 283 | 290 | 286 | 289 | 285 | 287 | 287 | 272 | 276 | 269
Run Code Online (Sandbox Code Playgroud)
此代码与repo中的代码之间的区别在于带分隔符的第二行与标题具有相同的列.之后,将显示此表
小智 10
不要忘记在表格前包含一个空行,否则它的格式将不正确。
| Attempt | #1 | #2 | #3 | #4 | #5 | #6 | #7 | #8 | #9 | #10 | #11 | #12 |
| :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: | :---: |
| Seconds | 301 | 283 | 290 | 286 | 289 | 285 | 287 | 287 | 272 | 276 | 269 | 254 |
Run Code Online (Sandbox Code Playgroud)
让您的示例更短,以便更容易理解.
| Attempt | #1 | #2 |
| :---: | :---: | :---: |
| Seconds | 301 | 283 |
Run Code Online (Sandbox Code Playgroud)
并格式化,使其更容易阅读.
| Attempt | #1 | #2 |
| :---: | :-: | :-: |
| Seconds | 301 | 283 |
Run Code Online (Sandbox Code Playgroud)
标题必须用竖线|字符分隔,并用-短划线字符加下划线.
您可以通过组合单词列表并使用连字符
-(对于第一行)进行分割,然后使用管道分隔每个列来创建表|.Run Code Online (Sandbox Code Playgroud)First Header | Second Header ------------- | ------------- Content Cell | Content Cell Content Cell | Content Cell出于美观目的,您还可以在末端添加额外的管道:
Run Code Online (Sandbox Code Playgroud)| First Header | Second Header | | ------------- | ------------- | | Content Cell | Content Cell | | Content Cell | Content Cell |
我们的例子变成:
| Attempt | #1 | #2 |
| ------- | --- | --- |
| Seconds | 301 | 283 |
Run Code Online (Sandbox Code Playgroud)
最后,通过在标题行中包含冒号:您可以将文本定义为左对齐,右对齐或居中对齐:
Run Code Online (Sandbox Code Playgroud)| Left-Aligned | Center Aligned | Right Aligned | | :------------ |:---------------:| -----:| | col 3 is | some wordy text | $1600 | | col 2 is | centered | $12 | | zebra stripes | are neat | $1 |
因此,为了居中对齐,我们的示例变为:
| Attempt | #1 | #2 |
| :-----: | :-: | :-: |
| Seconds | 301 | 283 |
Run Code Online (Sandbox Code Playgroud)
我使用 Markdown Table 工具 ( https://www.tablesgenerator.com/markdown_tables ),它帮助我从 csv 导入数据或将我的 html 表转换为 Markdown,我可以简单地将它复制到我的 README.md 文件中,这是一个真正的为我节省时间。
我通常会写一些我要发布在我的 README 文件上的 excel 文件,并将其保存为 csv 并导入到此工具中,然后复制粘贴生成的 Markdown,它会创建一个表,供其他人阅读您的说明。
希望有帮助。