Does :before not work on img elements?

后端 未结 12 2445
眼角桃花
眼角桃花 2020-11-22 01:46

I\'m trying to use the :before selector to place an image over another image, but I\'m finding that it simply doesn\'t work to place an image before an im

12条回答
  •  面向向阳花
    2020-11-22 02:22

    Unfortunately, most browsers do not support using :after or :before on img tags.

    http://lildude.co.uk/after-css-property-for-img-tag

    However, it IS possible for you to accomplish what you need with JavaScript/jQuery. Check out this fiddle:

    http://jsfiddle.net/xixonia/ahnGT/

    $(function() {
    
        $('.target').after('');
    
    });
    

    Edit:

    For the reason why this isn't supported, check out coreyward's answer.

提交回复
热议问题