Skip to content

Instantly share code, notes, and snippets.

@noobalex
Created January 2, 2020 02:45
Show Gist options
  • Save noobalex/a2fcc2a8373ee45a1d459aaa14769d7f to your computer and use it in GitHub Desktop.
Save noobalex/a2fcc2a8373ee45a1d459aaa14769d7f to your computer and use it in GitHub Desktop.
页面延迟加载
<style>
.page{position:relative;-ms-flex-direction:column;flex-direction:column;min-height:100vh}
.page-loading{background:center no-repeat;background-size:auto}
.js-hidden{display:none!important}
</style>
<div id="page-loading" class="page page-loading" style="background-image:url(../../img/loading-0.gif)"></div>
<div id="app" class="page js-hidden">
</div>
<script type="text/javascript">
window
.addEventListener("load", function () {
!function () {
var e = document.getElementById("app");
document.getElementById("page-loading")
.classList
.add("js-hidden"),
e.classList.remove("js-hidden")
}()
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment