我想结束了:使用Markdown,我如何将图像及其标题居中?
Hello there!
<image>
This is an image
Hi!
在图像和文本This is an image
在页面上居中。我如何用Markdown来完成这项工作?
编辑:请注意,我正在寻找水平中心的图像和文字在页面上。
我想结束了:使用Markdown,我如何将图像及其标题居中?
Hello there!
<image>
This is an image
Hi!
在图像和文本This is an image
在页面上居中。我如何用Markdown来完成这项工作?
编辑:请注意,我正在寻找水平中心的图像和文字在页面上。
您需要一个具有定义高度的块容器,line-height和vertical-align:middle相同的值; 它应该工作。
Hello there !
<div id="container">
<img />
This is an image
</div>
Hi !
#container {
height:100px;
line-height:100px;
}
#container img {
vertical-align:middle;
max-height:100%;
}
我想我只是想用水平对齐任何东西来使用HTML。
所以我的代码是这样的:
Hello there!
<center><img src="" ...></center>
<center>This is an image</center>
Hi!
如果您正在使用kramdown,你可以做到这一点
Hello there!
{:.center}
![cardinal](/img/2012/cardinal.jpg)
This is an image
Hi!
.center {
text-align: center;
}
在Mou(也许化身),这是很简单的。
-> This is centered Text <-
所以考虑到这一点,你可以将它应用于img语法。
->![alt text](/link/to/img)<-
此语法并不仅仅实现上的是什么Daring Fireball记录降价的实施工作。
随着kramdown(由githubpages使用)
{: style="text-align:center"}
That is, while there is value in the items on
the right, we value the items on the left more.
,或利用@我觉得我有这应该工作给予你可以定义CSS的解决方案的响应(史蒂芬竹)
{:.mycenter}
That is, while there is value in the items on
the right, we value the items on the left more.
<style>
.mycenter {
text-align:center;
}
</style>
这个。这是我出于某种原因痛苦地花了一个小时寻找的答案。 (第一个)谢谢@raisercostin。如果我能三次让你喜欢你,我会。 – Schwad 2017-08-03 09:02:14
这就是答案,现在我知道珠宝为什么在海底:wink: – 2017-08-05 22:30:47
,并且不需要任何扩展。首先您的降价图片代码:
![my image](/img/myImage.jpg#center)
请注意添加的网址hash #center。
现在CSS
img[src*='#center'] {
display: block;
margin: auto;
}
添加此规则,你应该能够使用URL的哈希像这样几乎就像定义一个类名。
它的工作!但你能解释为什么CSS部分工作?它只是设置为阻止和自动保证金。没有中心的风格。它如何居中? – 2017-05-12 22:15:35
在CSS中,当使用margin:auto时,元素将相对于其容器居中。 – tremor 2017-05-14 14:19:28
我可以在'div'中使用Markdown语法吗? – Chetan 2010-10-12 09:43:31
我认为Markdown不用于定位 – MatTheCat 2010-10-12 12:09:11
哦,我正在寻找水平居中。 – Chetan 2010-10-12 20:24:19