Tips for gracefully loading a web page?

后端 未结 4 1316
礼貌的吻别
礼貌的吻别 2021-01-16 07:43

I have a web page that has a lot of content that is hidden/shown/styled when the page is in various states using jQuery/javascript. I am running into an issue where on the

相关标签:
4条回答
  • 2021-01-16 08:11

    You can set the CSS display:none and visibility:hidden by default to your hidden elements.

    0 讨论(0)
  • 2021-01-16 08:24

    what about adding overlay and hide it when page load complete? :) try to add a div with id overlay or it's up to you, and style it like this :

    #overlay{
      width:100%;
      height:100%;
      position:fixed;
      top:0; left:0;
      z-index:99
    }
    

    this will hide all of your content. and after webpage load complete, hide it with jquery :

    $(window).load(function(){
      $('#overlay').animate({opacity:'0'}).css('zindex','-10');
    })
    
    0 讨论(0)
  • 2021-01-16 08:36

    This is known as a FOUC - a flash of unstyled content.

    A fairly standard way is to hide the content by default in your css and then once all the manipulation using javascript has been done show the elements again.

    However, rather than aiming for graceful degradation you may consider trying for progressive enhancement to enable javascript to add functionality to your site rather than relying on it for the functionality and appearance.
    See here for a good blog post on the relative merits of the two approaches.

    0 讨论(0)
  • 2021-01-16 08:37

    Use CSS to set the initial display state to hidden (display:none or visibility:hidden, as appropriate) and jQuery/JavaScript to show them later (either by direct styling or changing classes such that they appear.

    0 讨论(0)
提交回复
热议问题