<html>
<div id="loading"></div>
<div id="realbody">
//my real body here
</div>
</html>
<style type="text/css">
#loading {
background: url('my-loading-gif.gif') no-repeat center center;
position: absolute;
top: 0;
left: 0;
height: 100%;
width: 100%;
z-index: 9999999;
}</style>
<script>
function hideLoader() {
$('#loading').hide();
}
$(window).ready(hideLoader);
// Strongly recommended: Hide loader after 20 seconds, even if the page hasn't finished loading
setTimeout(hideLoader, 20 * 1000);
</script> I wanted to have a gif that is presented when my website is loading and I found this code online. But when I tried it, it played over the real body and didn't leave when my page had finished loaded.