我花了三个小时试图弄清楚如何在段落中正确地为浮动图像添加标题。我发现许多网站都涉及为图像添加字幕的任务,但没有一个网站涉及在段落中为图像添加字幕。这里的交易破坏者是无法在 p> 中包含除 em>、strong>、img> 等元素之外的元素。处理段落中的图像标题的最佳做法是什么?
我准备了一个jsfiddle:http: //jsfiddle.net/cm94k/
谢谢你
使用的html:
<h3>I want the red "kitten"-caption to be generated with html/css. (This one is in the image!)</h3>
<p>
eginning of the paragraph, but the end-tag is optional. Nevertheless, consistently including the end-tag is a good practice, and make certain types of automated processing easier. More importantly, it helps to make explicit
<img class="capimg" src="http://tinyurl.com/ppy7cuk" />
exactly where your paragraph really ends, which may differ quite significantly from where you as an author would have it. The ambiguity arises from the fact that HTML prescribes quite rigidly which elements may nest inside other elements. The only things that
</p>
使用的CSS:
p {
-moz-column-count:3; /* Firefox */
-webkit-column-count:3; /* Safari and Chrome */
column-count:3;
-moz-column-gap:2em; /* Firefox */
-webkit-column-gap:2em; /* Safari and Chrome */
column-gap:2em;
}
.capimg {
float: left;
width: 33%;
}