Ajax Loader
HTML
<nav>
1
<nav>
2
  <ul>
3
    <li><a href="#1">First</a></li>
4
    <li><a href="#2">Second</a></li>
5
    <li><a href="#3">Third</a></li>
6
    <li><a href="#4">Fourth</a></li>
7
    <li><a href="#5">Fifth</a></li>
8
  </ul>
9
</nav>
10
 
11
<div class="sections">
12
  <section id="1"><h1>First</h1></section>
13
  <section id="2"><h1>Second</h1></section>
14
  <section id="3"><h1>Third</h1></section>
15
  <section id="4"><h1>Fourth</h1></section>
16
  <section id="5"><h1>Fifth</h1></section>
17
</div>
18
 
19
<footer></footer>
20
 
21
<script class="cssdeck" src="//cdnjs.cloudflare.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
 
CSS
@import url(http://fonts.googleapis.com/css?family=Open+Sans);
1
@import url(http://fonts.googleapis.com/css?family=Open+Sans);
2
 
3
* {
4
  margin: 0;
5
  padding: 0;
6
  box-sizing: border-box;
7
}
8
 
9
body {
10
  font-family: 'Open Sans', sans-serif;
11
}
12
 
13
/* Navigation */
14
 
15
nav {
16
  width: 100%;
17
  height: 60px; 
18
  position: fixed; 
19
  top: 0;
20
  background: #1ABC9C;
21
}
22
 
23
nav ul {
24
  padding: 20px;
25
  margin: 0 auto;
26
  list-style: none;
27
  text-align: center;
28
}
29
nav ul li {
30
  display: inline-block;
31
  margin: 0 10px;
32
}
33
nav ul li a {
34
  padding: 10px 0;
35
  color: #fff;
36
  font-size: 1rem;
37
  text-decoration: none;
38
  font-weight: bold;
39
  transition: all 0.2s ease;
40
}
41
nav ul li a:hover {
42
  color: #34495E;
43
}
44
a.active {
45
  border-bottom: 2px solid #ecf0f1;
46
}
47
 
48
/* Headings */
49
 
50
h1 {
51
  font-size: 5rem;
52
  color: #34495E;
53
}
54
 
55
/* Sections */
56
 
57
section {
58
  width: 100%;
59
  padding: 50px;
60
  background: #fff;
61
  border-bottom: 1px solid #ccc;
62
  height: 500px;
63
  text-align: center;
64
}
65
section:nth-child(even) {
66
  background: #ecf0f1;
67
}
68
section:nth-child(odd) {
69
  background: #bdc3c7;
70
}
71
.sections section:first-child {
72
  margin-top: 60px;
73
}
74
section.active {}
75
 
76
footer {
77
  height: 500px;
78
  background: #34495e;
79
}
 
JavaScript
var sections = $('section')
1
var sections = $('section')
2
  , nav = $('nav')
3
  , nav_height = nav.outerHeight();
4
 
5
$(window).on('scroll', function () {
6
  var cur_pos = $(this).scrollTop();
7
  
8
  sections.each(function() {
9
    var top = $(this).offset().top - nav_height,
10
        bottom = top + $(this).outerHeight();
11
    
12
    if (cur_pos >= top && cur_pos <= bottom) {
13
      nav.find('a').removeClass('active');
14
      sections.removeClass('active');
15
      
16
      $(this).addClass('active');
17
      nav.find('a[href="#'+$(this).attr('id')+'"]').addClass('active');
18
    }
19
  });
20
});
21
 
22
nav.find('a').on('click', function () {
23
  var $el = $(this)
24
    , id = $el.attr('href');
25
  
26
  $('html, body').animate({
27
    scrollTop: $(id).offset().top - nav_height
28
  }, 500);
29
  
30
  return false;
31
});
 

Setting Active States on Sticky Navigations while Scrolling

CSSDeck G+