Provide zblog template_zblog them_wordpress template download and customization

Which starts to load the html image or the css background image first? How to operate the CSS bitmap?

Tianxing Studio 2020-04-10 14:10 Web special effects three thousand three hundred and fifty-seven 0 Comments


If your website It is a picture station, and the home page shows many pictures. Then you will have more images, which will cause slow loading. At this time, there are several solutions.

1. Physical solution: increase the bandwidth of the website+compress the image size;

2. Load js lazily with images. Before the images are loaded, load a buffer image to occupy the space;

3. That is what this article discusses. Use css to add a placeholder;


The first idea is to put a box around the outer layer of the picture, and then set a background image for the box.

Then during the test, it was found that this scheme did not work. When the picture was not loaded, the background picture of the box would not be displayed in time. It often disappeared when the picture was almost loaded.

According to the query data, when the browser renders the dom, it first loads the images in html, and then loads the background images in css. So this scheme will not have some effect


Another solution:

Use your brain in the pseudo class "after" of the outer box, set a "position: relative;" for the outer box, and then set a "position: absolute;" for the pseudo class with a width and height of 100%; Add a background color and the prompt text "content:" loading ";", and the effect picture is shown below:

 Which starts to load the html image or the css background image first? How to operate the CSS bitmap? Css background image lazy loading css bitmap page special effect page 1

Apart from no animation, this operation basically has its own functions.


welcome you Comment: Cancel Reply

 Please fill in the verification code
  • Latest articles
  • Hot article ranking
  • Most Comments
Label aggregation
  • Sign in
  • Registered account Forgot your password?
  • register
  • Already have an account? Direct login Forgot your password?
  • Social account login