pseudo element :before or :after on an image element

 ̄綄美尐妖づ 提交于 2019-12-10 11:46:39

问题


As far as I can tell you can't use :before or :after with text content on an image element? Is this correct? Am I missing something?

http://jsfiddle.net/rcztz/

I know semantically this isn't correct, I'm using because I'm appending the src to the image using js, but if there's no src I'd like to display alternative content (I could use another div, but it would be nice to just use :after or :before)


回答1:


This is correct. You are not able to use pseudo elements on images




回答2:


As lnrbob says, you cannot use pseudo elements on images. However, put a class on the image and use a background image and you'll be accomplishing the same thing.



来源:https://stackoverflow.com/questions/11846931/pseudo-element-before-or-after-on-an-image-element

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!