CSS Background Images not loading

后端 未结 5 838
独厮守ぢ
独厮守ぢ 2021-01-06 17:23

I\'ve got a very strange bug in chrome recently that is when you load the page first time, or in incognito mode that none of the background images show.

when you the

5条回答
  •  逝去的感伤
    2021-01-06 18:06

    Try this instead. Not tested though;

    $('*').each(function(){
    var bg = $(this).css('background');
    $(this).css('background', 'none');
    $(this).css('background', bg);
    });
    

    And make relevant changes (ie, background-image to background) in your CSS also.

    OR try;

    $('*').each(function(){
    var bg = $(this).css('background-image');
    $(this).css('background-image', 'none');
    $(this).css('background-image','url(bg)'); // or try url("bg") i am confused :P
    });
    

    From some search and research I came to a conclution;

    The way I would tackle this is with classes. Have a separate CSS classes for each of the states, then simply use jQuery to change the class. This would ensure that all of the images are actually downloaded and available when you set the class -- which is where I think Chrome is failing (probably all WebKit browsers would do this)

提交回复
热议问题