?
Solved

How to add loader animation to a page ?

Posted on 2016-11-11
2
Medium Priority
?
77 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 1000 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 58

Assisted Solution

by:Julian Hansen
Julian Hansen earned 1000 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

So you have coded your own WordPress plugin and now you want to allow users to upload images to a folder in the plugin folder rather than the default media location? Follow along and this article will show you how to do just that!
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 add a scalable full-width header using CSS3. Create a new HTML document with an internal stylesheet. Set a tiled background.:  Create a new div and name it Header. Position it with position:absolute at the top…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
Suggested Courses

752 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