我一直在研究GitHub中使用的Markdown语法,但除了将图像大小调整为README的宽度。md页面,我不知道如何在它的中心图像。
这可能吗?如果有,我该怎么做?
我一直在研究GitHub中使用的Markdown语法,但除了将图像大小调整为README的宽度。md页面,我不知道如何在它的中心图像。
这可能吗?如果有,我该怎么做?
当前回答
“纯”Markdown方法可以处理这个问题,将图像添加到表格中,然后将单元格居中:
|  |
| :--: |
它应该生成类似这样的HTML:
<table>
<thead>
<tr>
<th style="text-align:center;"><img src="img.png" alt="Image"></th>
</tr>
</thead>
<tbody>
</tbody>
</table>
其他回答
“纯”Markdown方法可以处理这个问题,将图像添加到表格中,然后将单元格居中:
|  |
| :--: |
它应该生成类似这样的HTML:
<table>
<thead>
<tr>
<th style="text-align:center;"><img src="img.png" alt="Image"></th>
</tr>
</thead>
<tbody>
</tbody>
</table>
表的方法
另一种方法是使用表。
<表> < tr > < td valign = "中心" > <span style="margin-bottom: 10px;">一些文本</span> . txt < / td > < td valign = "中心" > < img src = " https://github-readme-stats.vercel.app/api?用户名= hossein13m&show_icons = true&title_color = ffffff&icon_color = 34 abeb&text_color = daf7dc&bg_color = 151515 " / > < / td > < / tr > 表> < /
请记住,这将在GitHub自述文件上工作,但不适用于StackOverflow上的代码片段。
对于左对齐
<img align="left" width="600" height="200" src="https://www.python.org/python-.png">
为了正确对齐
<img align="right" width="600" height="200" src="https://www.python.org/python-.png">
对于中心对齐
<p align="center">
<img width="600" height="200" src="https://www.python.org/python-.png">
</p>
如果您觉得这有用,请在这里分叉以供将来参考。
它在GitHub上为我工作
<p align="center">
<img src="...">
</p>
您还可以将图像调整为所需的宽度和高度。例如:
<p align="center">
<img src="https://anyserver.com/image.png" width="750px" height="300px"/></p>
为图像添加居中标题,只需多一行:
<p align="center">This is a centered caption for the image<p align="center">
幸运的是,这对README都有效。md和GitHub Wiki页面。