Solved

How to add loader animation to a page ?

Posted on 2016-11-11
2
40 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 53

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Message not shown 5 34
jQuery not working on ELSE... why? 2 25
How can i get the length? 7 18
Window.Open() is showing a blank page 9 17
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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 tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…

863 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now