【发布时间】:2011-11-15 19:46:40
【问题描述】:
我正在尝试将 :before pseudo element 与 img 元素一起使用。
考虑一下这个 HTML 和 CSS...
HTML
<img src="http://0.gravatar.com/avatar/this-is-not-a-hash" alt="" />
CSS
img:before {
content: "hello";
}
这不会产生预期的效果(在 Chrome 13 和 Firefox 6 中测试)。但是,它适用于 div 或 span 元素。
为什么不呢?
有没有办法让伪元素与img 元素一起工作?
【问题讨论】:
-
我写了这个(不是很好)相关的答案:stackoverflow.com/questions/6949148/…
标签: css pseudo-element css-content