Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/84.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/39.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/amazon-s3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 为图像添加字幕_Html_Css_Markup_Semantic Markup - Fatal编程技术网

Html 为图像添加字幕

Html 为图像添加字幕,html,css,markup,semantic-markup,Html,Css,Markup,Semantic Markup,使用最新的HTML/CSS在web上创建标题图像的最简洁的方法是什么?请输入演示代码。编辑- 很好的例子 其他示例:我知道我在www.alistampart.com上看到了许多文章,其中包含一些好的代码,但这里有一个例子可以让您开始:有几种语义方法可以标记图像及其标题 老一套 传统的方法是使用HTML定义列表,请参阅。(还有其他方法可以演示此方法。) 福 微格式 还有一种适用于任何常规标记的方法: <div class="figure"> <img class="ima

使用最新的HTML/CSS在web上创建标题图像的最简洁的方法是什么?请输入演示代码。

编辑-

很好的例子


其他示例:

我知道我在www.alistampart.com上看到了许多文章,其中包含一些好的代码,但这里有一个例子可以让您开始:

有几种语义方法可以标记图像及其标题

老一套 传统的方法是使用HTML定义列表,请参阅。(还有其他方法可以演示此方法。)

微格式 还有一种适用于任何常规标记的方法:

<div class="figure">
  <img class="image" src="foo.jpeg" alt="" /><br/>
  <small class="legend">Foo</small>
</div>


HTML5 HTML5现在提供了一种简洁明了的方法,用于通过网络显示带有标题的图像


这就是我要做的

.img-container {position:relative;}
,img-container h4{position:absolute;bottom:0; left:0;height:Npx;line-height:20px; font-size:18px;}
.img-container img {margin-bottom:Npx;} 
如果存在文本在多行上运行的风险,您将希望使N的值更大,否则20px就可以了

<div class="img-container">
<h4 class="caption">A picture of a dog</h4> //or h3, or h5 etc... - whichever is most appropriate given how you've used headings on your site
<img src,,,,>
</div>

狗的照片//或h3或h5等考虑到您在网站上使用标题的方式,以最合适的为准

将标题放在标记中的图像之前,并将其作为标题,我认为从语义上讲,你可以说“这是……的图片”

很难在这里的帖子中列出所有细节

以下是一些深入讨论CSS图像字幕的链接:

最后是一个独立工具,用于生成图像标题所需的CSS代码:


您可以使用这些酷炫的图像字幕效果


我已经听到CSS纯粹主义者因为这张桌子而心脏病发作……好吧,我想你可能会说一张桌子上只有一张图片,因为它的标题部分与“用于布局的桌子”的行相冲突——你可以说,我会用这个:)这是我最喜欢的许多可能的方法。@Torok-谢谢+1.但是“图像标题语义方式”链接已经失效:(这里是到的链接;也就是说,除了上面已经给出的示例之外(使用a),这篇文章仅仅讨论了作者是如何得出这个解决方案的。我无法比这篇文章更好地解释它:我想说,在这个链接中使用表格的示例是错误的。表格应该用于排列数据。我同意你的观点……但是,这个链接还提供了使用纯CSS设置标题格式的方法。表格布局有一些例子可以提供其他方法来实现这一点。我认为有很多方法是一个好主意。我强烈建议使用DIV-only布局。这篇文章(最初由@jgallant发布)似乎解决了OP的问题:
.img-container {position:relative;}
,img-container h4{position:absolute;bottom:0; left:0;height:Npx;line-height:20px; font-size:18px;}
.img-container img {margin-bottom:Npx;} 
<div class="img-container">
<h4 class="caption">A picture of a dog</h4> //or h3, or h5 etc... - whichever is most appropriate given how you've used headings on your site
<img src,,,,>
</div>