How to hide image broken Icon using only CSS/HTML?

前端 未结 17 1812
不思量自难忘°
不思量自难忘° 2020-11-27 09:14

How can I hide the broken image icon? Example: \"Example\"

I have an image with error src:

17条回答
  •  悲哀的现实
    2020-11-27 09:49

    Using CSS only is tough, but you could use CSS's background-image instead of tags...

    Something like this:

    HTML

    CSS

    #image {
        background-image: url(Error.src);
        width: //width of image;
        height: //height of image;
    
    }
    

    Here is a working fiddle.

    Note: I added the border in the CSS on the fiddle just to demonstrate where the image would be.

提交回复
热议问题