IMG标记的CSS内容属性 [英] CSS Content attribute for IMG tag
本文介绍了IMG标记的CSS内容属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
img:after {
content:attr(title);
}
这不工作,可能是因为img标记为空, 。解决方案
img
是一个 strong>替换元素,并且 w3c CSS 2.1规范说明:
注意。这个规范没有
完全定义
:before和:after与替换的
元素(例如HTML中的IMG)之间的交互。这个
将在未来的规范中更详细地定义。
我不知道任何未来规范发生。它不工作在Chrome,这是肯定的:)。
img:after {
content:attr(title);
}
This is not working, probably because the img tag is empty, no closing tag. Any workaround to fix this without js?
解决方案
img
is a replaced element, and the w3c CSS 2.1 spec says:
Note. This specification does not fully define the interaction of :before and :after with replaced elements (such as IMG in HTML). This will be defined in more detail in a future specification.
I don't know about any "future specification" that took place. It does not work in Chrome, that's for sure :).
这篇关于IMG标记的CSS内容属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文