Placeholder background/image while waiting for full image to load?

前端 未结 11 1629
栀梦
栀梦 2020-12-13 03:36

I have a few images on my page. I\'m finding that the page starts to render before the images have been loading (which is good), but that the visual effect is not great. Ini

11条回答
  •  情深已故
    2020-12-13 04:20

    It's very simple.. This scenario allows to load profile photo that default placeholder image. You could load multi css background-image into an element. When avatar photo fails, the placeholder image appears default of div.

    If you're using a div element that loads via css background-image, you could use this style:

        #avatarImage {
            background-image: url("place-holder-image.png"), url("avatar-image.png");
        }
    
        

提交回复
热议问题