HTML Loading Animation

前端 未结 1 1597
轻奢々
轻奢々 2021-01-19 06:20

I have a website that loses layout scheme while the page isn\'t loaded.

What I\'d like to do is to have an animation linked to the loading progress, like a progress

1条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-19 07:01

    You could easily achieve this using some basic CSS, and then writing a function to "update" the value you assign to the CSS of the page that would, while the page is not loaded/the loading bar is not fully opaque then it will carry on running.

    This can easily be achieved with JQuery or JavaScript.

    To actually get information on the loading of the DOM, you can use Progress Events. The example given in the documentation of Progress Events is this:

    
    Waiting for Magical Unicorns
    
    
    

    So in this example you are loading "magical-unicorns", and assigning the parapgraph

    the current loaded percentage. To change this to modify the CSS I would use JavaScript to change your opacity eg. document.getElementById("myLoadBar").style.opacity = "0.5";

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