【发布时间】:2021-10-25 18:38:05
【问题描述】:
我尝试创建一个从属性值生成的纯 CSS IMG-Tooltip。 我尝试了以下代码
<img src="blabla.jpg" data-caption="this is my caption" />
和 CSS 代码:
img {
position: relative;
}
img:after {
content: attr(data-caption);
position: absolute;
bottom: 2em;
left: 2em;
z-index: 2
}
这样的方式对于 div 容器是没有问题的。但是我怎样才能让这个工作在图像上呢?
谢谢你, 托马斯
【问题讨论】:
-
图片不能有伪元素。