How to Preload Images without Javascript?

后端 未结 9 1406
有刺的猬
有刺的猬 2020-12-01 02:48

In one of My Layout there are some large images (come from XML) which shown when I mouse hover on some some of the link, but when the Page loads and when i rollover It takes

9条回答
  •  余生分开走
    2020-12-01 03:19

    From http://snipplr.com/view/2122/css-image-preloader

    A low-tech but useful technique that uses only CSS. After placing the css in your stylesheet, insert this just below the body tag of your page: Whenever the images are referenced throughout your pages they will now be loaded from cache.

    #preloadedImages
    {
        width: 0px;
        height: 0px;
        display: inline;
        background-image: url(path/to/image1.png);
        background-image: url(path/to/image2.png);
        background-image: url(path/to/image3.png);
        background-image: url(path/to/image4.png);
        background-image: url();
    
    }
    

提交回复
热议问题