forked from davist11/jQuery-One-Page-Nav
-
Notifications
You must be signed in to change notification settings - Fork 0
/
top.html
90 lines (83 loc) · 3.82 KB
/
top.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>jQuery One Page Nav</title>
<link href="demo.css" rel="stylesheet" media="all">
<style>
.section-wrapper {
margin-top: -50px;
padding-top: 50px;
}
.section-wrapper:first-child .section {
padding-top: 100px;
}
#nav {
background: #000;
left: 0;
list-style: none;
overflow: hidden;
padding-top: 9px;
position: fixed;
right: 0;
text-align: center;
top: 0;
}
#nav li {
display: inline-block;
margin-bottom: 0;
}
#nav a {
background: #000;
color: #fff;
display: block;
padding: 10px;
}
#nav a:hover {
background: none;
color: #dedede;
}
#nav .current a {
background: #fff;
color: #000;
}
</style>
</head>
<body>
<ul id="nav">
<li class="current"><a href="#section-1">Section 1</a></li>
<li><a href="#section-2">Section 2</a></li>
<li><a href="#section-3">Section 3</a></li>
</ul>
<div id="container">
<div class="section-wrapper" id="section-1">
<div class="section">
<h1>Horizontal Nav</h1>
<p>To account for the offset of the horizontal nav, add top negative margin and top padding. For example, the navigation on this page is 50px tall. So to each section, add a -50px top margin and 50px to offset the height of the nav. That means when you go to each section, it will scroll to the exact top of the section while accounting for the height of the nav.</p>
</div>
</div>
<div class="section-wrapper" id="section-2">
<div class="section">
<h2>Section 2</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</div>
</div>
<div class="section-wrapper" id="section-3">
<div class="section">
<h2>Section 3</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</div>
</div>
</div>
<!--[if lte IE 8]><script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script><![endif]-->
<!--[if gt IE 8]><!--><script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script><!--<![endif]-->
<script src="jquery.nav.js"></script>
<script>
$(document).ready(function() {
$('#nav').onePageNav();
});
</script>
</body>
</html>