Last active
May 2, 2022 02:56
-
-
Save obrenoco/54f1e0923239e3243fe7f01e9dd47e6f to your computer and use it in GitHub Desktop.
pre-loading
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id="loading-page" class="loading-page"> | |
<div class="loader"></div> | |
</div> | |
<div class="content"> | |
<h1>Page loaded!</h1> | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.addEventListener("load", () => { | |
document.getElementById("loading-page").classList.add("loaded"); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
body { | |
margin: 0; | |
} | |
.content { | |
display: flex; | |
align-items: center; | |
justify-content: center; | |
height: 100vh; | |
} | |
.loading-page { | |
position: absolute; | |
width: 100%; | |
background-color: black; | |
height: 100vh; | |
display: flex; | |
align-items: center; | |
justify-content: center; | |
} | |
.loading-page.loaded { | |
transition: transform 0.8s ease-in-out; | |
transform: translate(-100%, 0); | |
} | |
.loader { | |
border: 16px solid #f3f3f3; | |
border-top: 16px solid #3498db; | |
border-radius: 50%; | |
width: 120px; | |
height: 120px; | |
animation: spin 0.5s linear infinite; | |
} | |
@keyframes spin { | |
0% { | |
transform: rotate(0deg); | |
} | |
100% { | |
transform: rotate(360deg); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment