Using CSS instead of Javascript for Preloading Images


/ Published in: CSS
Save to your folder(s)



Copy this code and paste it in your HTML
  1. /* CSS3 */
  2. .preload {
  3. background-image: url(images/image_01.png),
  4. url(images/image_02.png),
  5. url(images/image_03.png),
  6. url(images/image_04.png),
  7. url(images/image_05.png);
  8. background-position: -9999px -9999px;
  9. background-repeat: no-repeat;
  10. }
  11.  
  12. /* CSS2 */
  13. .preload-01{ background: url(images/image_01.png) no-repeat -9999px -9999px;}
  14. .preload-02{ background: url(images/image_02.png) no-repeat -9999px -9999px;}
  15. .preload-03{ background: url(images/image_03.png) no-repeat -9999px -9999px;}
  16. .preload-04{ background: url(images/image_04.png) no-repeat -9999px -9999px;}
  17. .preload-05{ background: url(images/image_05.png) no-repeat -9999px -9999px;}

URL: http://forrst.com/posts/Using_CSS_instead_of_Javascript_for_Preloading_I-w0A

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.