Ajax Loader
×
HTML
<div class="container">
1
<div class="container">
2
 
3
      <img class="frame" src="https://static1.squarespace.com/static/54df85cde4b065fefa528754/56bc7bfae32140fb82eb052c/56c091bf86db43f2a5b41178/1455460800053/Screen+Shot+2016-02-14+at+15.37.52.png?format=1000w" />
4
  
5
 <div class="birdgif_container">
6
    
7
  <img id="bird_gif" src="https://static1.squarespace.com/static/54df85cde4b065fefa528754/56bc7bfae32140fb82eb052c/56c090ebf699bb2d67dbb92b/1455460607074/Untitled.gif?format=1000w" style="height:450px; "/>
8
  
9
      </div>
10
  
11
 
12
  <div class="bird_container">
13
    
14
  <img id="bird" src="https://static1.squarespace.com/static/54df85cde4b065fefa528754/56bc7bfae32140fb82eb052c/56c090ebf850826907607226/1455460589128/Screen+Shot+2016-02-14+at+15.34.44.png?format=1000w" style="height:450px; "/>
15
    
16
      </div>
17
 
18
  
19
 
20
  </div>
 
CSS
.container {
1
.container {
2
    position: relative;
3
    width: 300px;
4
}
5
 
6
.frame {
7
    position: absolute;
8
    height: 600px;
9
    pointer-events: none;
10
}
11
 
12
div.bird_container {
13
  position: absolute;
14
  margin: 70px 0px 0px 21px;
15
  
16
}
17
 
18
div.birdgif_container {
19
  position: absolute;
20
  margin: 70px 0px 0px 21px;
21
  
22
}
23
 
24
 
25
 
 
JavaScript
(new Image()).src = "bird.gif"; // this would preload the GIF, so future loads will be instantaneous
1
(new Image()).src = "bird.gif"; // this would preload the GIF, so future loads will be instantaneous
2
 
3
var bird = document.getElementById('bird'),
4
    bird_gif = document.getElementById('bird_gif');
5
 
6
bird.onclick = function() {
7
    bird.src = bird_gif;
8
    document.getElementById('bird').style.display = 'none';
9
}
10
 
11
bird_gif.onclick = function() {
12
    bird_gif = bird.src;
13
      document.getElementById('bird_gif').style.display = 'none';
14
 
15
 
16
}
 

Testy test 2

CSSDeck G+