-2

I want to display pre-load image center of image's div. But all images have different size so pre-load image can not be displayed in center of each image.

Thanks for advance!

oxygen
  • 151
  • 2
  • 3
  • 14

1 Answers1

0

You can use css to resolve this problem. Add class "pre-loader" to every image on your page, and describe it with css:

.pre-loader {
  background: #ccc url(loaderimageurl) center center no-repeat;
}

Then use js like this:

$("img").load(function () { $(this).removeClass("pre-loader"); });
Vladislav Qulin
  • 1,872
  • 1
  • 17
  • 20
  • to the best i recommend you to and `min-width` and `min-height` to every image – whytobe Aug 03 '12 at 12:50
  • it can ruin the makeup. and small images will be loaded quick enough. i guess. imo thats bad idea to put loaders on images. – Vladislav Qulin Aug 03 '12 at 12:51
  • I tried your offer. load image can not be displayed if width and heigh is not determined. when I determine width and height and when I addClass to all images, all of these image resized to load image. – oxygen Aug 03 '12 at 13:54
  • You can determine those parameters in css-rule for .pre-loader, like np. – Vladislav Qulin Aug 04 '12 at 06:44