Skip to content

Instantly share code, notes, and snippets.

@z-------------
Created March 4, 2014 00:11
Show Gist options
  • Save z-------------/9337510 to your computer and use it in GitHub Desktop.
Save z-------------/9337510 to your computer and use it in GitHub Desktop.
JS + CSS fade effect
<style>
body {
opacity:0; /* invisible at first */
transition:opacity 1s; /* transition opacity for 1 second */
}
</style>
<script>
document.addEventListener("DOMContentLoaded",function(){ // equivalent to jQuery ready()
document.body.style.opacity = "1"; // set body's opacity to 1
})
/* this method is much better than using jQuery since you don't have to load a huge library
* to do a simple effect like a fade
* pls use it */
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment