我一直在研究GitHub中使用的Markdown语法,但除了将图像大小调整为README的宽度。md页面,我不知道如何在它的中心图像。

这可能吗?如果有,我该怎么做?


当前回答

您还可以将图像调整为所需的宽度和高度。例如:

<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页面。

其他回答

这是来自GitHub的支持:

Markdown不允许你直接调整对齐(见文档这里:http://daringfireball.net/projects/markdown/syntax#img),但你可以只使用原始HTML 'img'标签,并与内联css对齐。

因此,对齐图像是可能的!你只需要使用内联CSS来解决这个问题。你可以从我的GitHub存储库中拿一个例子。在README的底部。这是一个居中对齐的图像。为了简单起见,你可以这样做:

<p align="center">
  <img src="http://some_place.com/image.png" />
</p>

尽管,正如nulltoken所说,这将是与Markdown哲学的边缘!


这段代码来自我的README文件:

<p align="center">
  <img src="https://github.com/waldyr/Sublime-Installer/blob/master/sublime_text.png?raw=true" alt="Sublime's custom image"/>
</p>

它产生以下图像输出,除了在GitHub上查看时居中:

<p align="center">
  <img src="https://github.com/waldyr/Sublime-Installer/blob/master/sublime_text.png?raw=true" alt="Sublime's custom image"/>
</p>

我不知道为什么没有人提到<center>标签。更多阅读请参考医生。

<center>
    <h1>Hola App</h1> 
    <img src="root/static/assets/img/beer.svg">
</center>

它在GitHub上为我工作

<p align="center">
    <img src="...">
</p>

为了扩展答案以支持本地图像,只需将FILE_PATH_PLACEHOLDER替换为图像路径并检查它。

<p align="center">
  <img src="FILE_PATH_PLACEHOLDER">
</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页面。