Home » , » Using a Gif and CSS on Large Images

Using a Gif and CSS on Large Images

Written By GA Team on Thursday 19 February 2015 | 11:27 pm

GNN Ads

What?

Using CSS you can put an image as the background image of any images on your web site. Sounds confusing but a image is just a normal HTML DOM element, which means you can add the same CSS attributes to it such as borders and backgrounds.

If you have a website which has large images to load on the page the user will need to wait for them to load leaving a blank space on the screen.

Why?

If you place a background image on all images this will load before the image loads,

So all you have to do is create a smaller image such as a loading gif this will be loaded and it will be displayed in place of the larger image, when the larger image finishes loading it will replace the smaller image.

How?

Just create a small gif loading image and upload it to your website. Then change your CSS by adding this near the top of the CSS file.
img {
     background: url(images/loading.gif) no-repeat;
}

GNN Ads

Join Our Email Newsletter Now!

Join over 10,000 people who get free and fresh content delivered automatically each time we publish.

https://lh4.googleusercontent.com/-7ZpSgX9Y-dc/UPkMMxmfkRI/AAAAAAAAVQA/nyPxtCTQwtQ/s125/advertise125x125.gif.png https://lh4.googleusercontent.com/-7ZpSgX9Y-dc/UPkMMxmfkRI/AAAAAAAAVQA/nyPxtCTQwtQ/s125/advertise125x125.gif.png https://lh4.googleusercontent.com/-7ZpSgX9Y-dc/UPkMMxmfkRI/AAAAAAAAVQA/nyPxtCTQwtQ/s125/advertise125x125.gif.png https://lh4.googleusercontent.com/-7ZpSgX9Y-dc/UPkMMxmfkRI/AAAAAAAAVQA/nyPxtCTQwtQ/s125/advertise125x125.gif.png

Total views

Advertise Here

Most Popular Posts

Latest

Advertise with GNN

Advertise with GNN P/D
GNN ADS