【发布时间】:2015-05-28 00:12:35
【问题描述】:
我正在使用 span 元素为带有标题的图像创建容器。我想将图像居中放在它自己的线上,就像我使用
<span class="imageholder" style="width:150px">
<a href="https://gallery.mailchimp.com/37f4256f7c29a1b3335eb535e/images/62f05d38-ae67-40d1-bf14-7773330b8169.jpg" target="new"><img src="https://gallery.mailchimp.com/37f4256f7c29a1b3335eb535e/images/62f05d38-ae67-40d1-bf14-7773330b8169.jpg" width="100%" alt="Roux and Mary at the Good Food Festival"></a>
<span class="caption" style="width:150px">Roux and Mary at the Good Food Festival
</span>
</span>
jsfiddle
顶部图像是我正在寻找的结果,减去容器。中间图像显示了带有标题的容器,使用“float:left”。底部的图像是我要居中的图像。
谢谢!
【问题讨论】:
-
jsfiddle Adam 中似乎只有两张图片。上中下图是哪一张??
-
<center>已被弃用,不再在 HTML5 中使用。此外,将所有内联样式提取到适当的样式表会很有帮助 -
target="new"应该是target="_blank"