Solved

How to add loader animation to a page ?

Posted on 2016-11-11
2
49 Views
Last Modified: 2016-11-12
Hi Experts,

Am just curious about how to add Css or js animation loader to my page and how does it working and is there any tutorial on this

Thanks Experts
0
Comment
Question by:karthik80c
2 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 250 total points
ID: 41883719
to write simple, you can have something like :
test page : https://jsfiddle.net/ueLkgju7/2/

<head>
  <style>
     .overlay {
         top:0;
         left:0;
         position:absolute;
         width:100%;
         height:100%;
         background-color:white;
     }
     .overlay img {
        display: block;
        margin-left: auto;
        margin-right: auto;
     }
  </style>
   <script>
          window.onload = function() {
              document.getElementById("hide_me_when_page_loaded").style.display = "none";
          }
  </script>
</head>
<body>
   <div class="overlay" id="hide_me_when_page_loaded"><img src="" /></div>
your page content follow
</body>

Open in new window


you've lot of tuto using Google search, for example : http://smallenvelop.com/display-loading-icon-page-loads-completely/
1
 
LVL 54

Assisted Solution

by:Julian Hansen
Julian Hansen earned 250 total points
ID: 41883755
Another sample
HTML
<body>
<div id="loader"></div>
...
</body>

Open in new window

CSS
<style type="text/css">
#loader {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,.75) url(images/loading2.gif) no-repeat center center;
}
</style>

Open in new window

JavaScript
<script>
window.addEventListener('load', function() {
  var loader = document.getElementById('loader');
  loader.parentNode.removeChild(loader);
});
</script>

Open in new window

Working sample here

EDIT: remove() not supported everywhere updated to use parentNode.removeChild
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer …
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
In this Micro Tutorial viewers will learn how to create a CSS image sprite (In a later tutorial, viewers will learn how to use CSS and HTML to create a navigation menu using this sprite) Open a new Photoshop document with a width of (Icon width)x(N…
In this tutorial viewers will learn how to embed custom externally-hosted Google Fonts using the Google Font API in CSS Go to the Google Fonts website at google.com/fonts: Browse or search based on font properties or name to find a suitable font for…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question