-
Notifications
You must be signed in to change notification settings - Fork 9
/
standalone_ver.html
482 lines (423 loc) · 14.7 KB
/
standalone_ver.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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
<!-- Standalone version is no longer maintained (as of 2020/12) and is kept for legacy purposes only. The version is 1.2.1. -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Simply Navigation - Stand-alone version</title>
<style>
html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, embed, figure, figcaption, footer, header, hgroup, menu, nav, output, section, summary, time, mark, audio, video, .row {
margin: 0;
padding: 0;
border: 0;
vertical-align: baseline; }
article, footer, header, nav, section {
display: block; }
*, *:before, *:after {
box-sizing: border-box;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box; }
html {
width: 100%;
height: 100%; }
body {
background-color: #1d1d1d;
margin: 0 auto;
overflow-x: hidden;
font-size: 1rem;
font-feature-settings: kern;
-ms-font-feature-settings: kern;
-o-font-feature-settings: kern;
font-kerning: normal;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-osx-font-smoothing: grayscale;
-webkit-text-size-adjust: 100%;
scroll-behavior: smooth; }
html, body {
min-width: 320px;
font-size: 17px; }
body, input, select, textarea {
font-family: -apple-system, BlinkMacSystemFont, "Roboto", "Segoe UI", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", Arial, sans-serif;
color: rgba(244, 248, 251, 0.75);
font-weight: 400;
line-height: 1.5; }
a, a:visited {
-moz-transition: color 0.2s ease-in-out, border-style 0.2s ease-in-out;
-webkit-transition: color 0.2s ease-in-out, border-color 0.2s ease-in-out;
-ms-transition: color 0.2s ease-in-out, border-style 0.2s ease-in-out;
transition: color 0.2s ease-in-out, border-style 0.2s ease-in-out;
color: #F0DB4F;
text-decoration: none;
outline: none; }
a:hover, a:visited:hover {
color: #dfc513;
text-decoration: none; }
strong, b {
color: #F4F8FB;
font-weight: 600; }
em {
font-style: italic; }
p {
margin-top: 1rem;
margin-bottom: 1rem;
color: rgba(244, 248, 251, 0.75);
max-width: 40rem; }
p:first-of-type {
margin-top: 0; }
h1, h2, h3, h4, h5, h6 {
color: rgba(244, 248, 251, 0.75);
font-family: -apple-system, BlinkMacSystemFont, "Roboto", "Segoe UI", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", Arial, sans-serif;
font-weight: 700;
margin-left: auto;
margin-right: auto; }
h1 {
font-size: 2rem;
margin-top: 2rem;
color: #F4F8FB; }
h2 {
font-size: 1.6rem;
margin-top: 1.35rem;
margin-bottom: 1.35rem;
letter-spacing: 0.1px; }
h3 {
font-size: 1.3rem;
margin-top: 1rem;
margin-bottom: 1rem; }
h4, h5, h6 {
font-size: 1.1rem;
margin-bottom: 1rem;
font-weight: 500; }
ul {
margin: 0 0 1rem 0;
padding-left: 0.75rem; }
ul li {
padding-left: 0.25rem;
margin-bottom: 0.25rem; }
button {
background: #F0DB4F;
color: #2a2a2a;
border: 0;
border-radius: 3px;
font-size: 1rem;
margin: 0 0.15rem;
padding: 0.25rem 0.5rem;
cursor: pointer; }
button:hover {
background: #ecd120; }
main {
margin: 6.5rem auto 0 auto; }
main section {
padding: 1rem;
max-width: 60rem;
margin: 0 auto; }
/* ///////////////////
NAVIGATION CSS
STARTS HERE
////////////////////
*/
.nav-wrapper {
background-color: #434343;
position: absolute;
top: 0;
left: 0;
right: 0;
height: 4.5rem;
width: 100%;
margin: 0 auto;
z-index: 95;
padding: 0;
display: block;
backface-visibility: hidden;
transform-style: preserve-3d;
-webkit-backface-visibility: hidden;
-webkit-transform-style: preserve-3d;
transition: all 0.2s ease-in-out;
-webkit-transition: all 0.2s ease-in-out; }
.nav-wrapper.sticky-nav {
position: fixed; }
.nav {
max-width: 80rem;
width: 100%;
margin: 0 auto;
padding: 0;
display: flex;
justify-content: center; }
.nav__list {
background-color: transparent;
list-style: none;
margin: 0;
padding: 0;
display: block;
position: fixed;
top: -0.25rem;
bottom: 0;
left: 0;
width: 0;
min-height: 102vh;
overflow: hidden;
-webkit-overflow-scrolling: touch;
z-index: 99;
transition: all 0.4s cubic-bezier(0.18, 0.89, 0.32, 1.28);
backface-visibility: hidden;
transform-style: preserve-3d;
-webkit-backface-visibility: hidden;
-webkit-transform-style: preserve-3d; }
.nav__list li {
display: flex;
padding: 0;
border-bottom: 1px solid rgba(202, 207, 204, 0.5); }
.nav__list li:first-child {
margin-top: 1rem; }
.nav__list li:last-child {
border-bottom: 0; }
.nav__list .nav__item {
border-color: transparent;
padding: 0.75rem 1rem 0.5rem 1rem;
flex-basis: 100%;
display: block;
background: transparent;
font-size: 1.5rem;
padding-left: 1.5rem;
color: rgba(244, 248, 251, 0.75);
transition: all 0.3s ease-in-out; }
.nav__list .nav__item:hover, .nav__list .nav__item.active {
color: #F0DB4F; }
.nav__logo {
z-index: 90;
border-bottom: 0;
padding: 0.5rem;
backface-visibility: hidden;
transform-style: preserve-3d;
-webkit-backface-visibility: hidden;
-webkit-transform-style: preserve-3d;
position: absolute;
right: 1rem; }
.logo {
z-index: 92;
max-height: 25vh;
max-width: 100%;
backface-visibility: hidden;
transform-style: preserve-3d;
-webkit-backface-visibility: hidden;
-webkit-transform-style: preserve-3d;
transition: max-height 0.2s ease-in-out;
-webkit-transition: max-height 0.2s ease-in-out; }
.logo.logo-small {
z-index: 99;
max-height: 3.5rem;
backface-visibility: hidden;
transform-style: preserve-3d;
-webkit-backface-visibility: hidden;
-webkit-transform-style: preserve-3d;
transition: max-height 0.2s ease-in-out;
-webkit-transition: max-height 0.2s ease-in-out; }
.page__overlay {
width: 40%;
height: 100%;
background: rgba(67, 67, 67, 0.65);
position: absolute;
right: 0;
top: 0;
cursor: pointer; }
.nav__list-left {
background: #1d1d1d;
width: 60%;
height: 100%;
position: relative; }
.nav__list-right {
width: 40%; }
#sideNav.open {
width: 100%; }
.toggleNav, .toggleNav:focus, .toggleNav:active {
display: block;
z-index: 91;
color: white;
padding: 1rem;
font-size: 1.5rem;
cursor: pointer;
left: 0.5rem;
position: absolute;
transition: all 0.3s;
-webkit-transition: all 0.3s; }
.svg-hamburger, .svg-close {
width: 1.25rem;
height: 1.25rem; }
.closeBtn, .closeBtn:visited, .closeBtn:active, .closeBtn:focus {
cursor: pointer;
font-size: 1.75rem;
font-weight: 800;
display: flex;
background: transparent;
border-bottom: 0;
padding: 1.25rem 1rem 1rem 1.5rem;
margin: 0;
text-align: left;
color: #434343;
transition: all 0.3s;
-webkit-transition: all 0.3s; }
.closeBtn span, .closeBtn:visited span, .closeBtn:active span, .closeBtn:focus span {
font-size: 1rem;
padding-left: 0.25rem; }
.closeBtn span:hover, .closeBtn:visited span:hover, .closeBtn:active span:hover, .closeBtn:focus span:hover {
color: rgba(244, 248, 251, 0.75); }
.closeBtn .svg-close, .closeBtn:visited .svg-close, .closeBtn:active .svg-close, .closeBtn:focus .svg-close {
margin-top: 0.75rem; }
.closeBtn .svg-close-path:hover, .closeBtn:visited .svg-close-path:hover, .closeBtn:active .svg-close-path:hover, .closeBtn:focus .svg-close-path:hover {
fill: #F0DB4F; }
.closeBtn:hover, .closeBtn:visited:hover, .closeBtn:active:hover, .closeBtn:focus:hover {
color: rgba(244, 248, 251, 0.75); }
@media all and (min-width: 800px) {
.toggleNav {
display: none; }
.closeBtn {
display: none; }
.nav__logo {
margin-left: 1rem;
position: relative;
right: unset; }
.nav__list {
margin-top: 0.5rem;
position: relative;
width: 100%;
min-height: initial;
background: transparent;
z-index: 1;
overflow: hidden; }
.nav__list li {
padding: 1.25rem 0;
margin-left: 1.5rem;
border-bottom-color: transparent;
justify-content: flex-start; }
.nav__list .nav__item {
border-bottom: 2px solid transparent;
display: block;
flex-basis: unset;
background: transparent;
padding: 0;
font-size: 1rem;
outline: 0;
transition: all 0.2s ease-in-out; }
.nav__list-left, .nav__list-right {
width: unset;
height: unset;
overflow: hidden; }
.nav__list-left {
border-top: 0;
background: transparent;
display: flex;
align-items: center; }
.nav__list-right {
display: none;
z-index: -1; } }
</style>
</head>
<body>
<header class="nav-wrapper">
<nav class="nav" role="navigation">
<span class="toggleNav">
<svg class="svg-hamburger" viewBox="0 0 1536 1280" xmlns="http://www.w3.org/2000/svg">
<path class="svg-hamburger-path" d="M1536 1088v128q0 26-19 45t-45 19H64q-26 0-45-19t-19-45v-128q0-26 19-45t45-19h1408q26 0 45 19t19 45zm0-512v128q0 26-19 45t-45 19H64q-26 0-45-19T0 704V576q0-26 19-45t45-19h1408q26 0 45 19t19 45zm0-512v128q0 26-19 45t-45 19H64q-26 0-45-19T0 192V64q0-26 19-45T64 0h1408q26 0 45 19t19 45z" fill="rgba(226, 241, 236, 20.85)" />
</svg>
</span>
<a class="nav__logo" href="#">
<img class="logo logo-small" id="logo" src="https://upload.wikimedia.org/wikipedia/commons/thumb/6/6a/JavaScript-logo.png/480px-JavaScript-logo.png" alt="Logo">
</a>
<ul class="nav__list" id="sideNav">
<div class="nav__list-left">
<a class="closeBtn">
<svg class="svg-close" viewBox="0 0 1188 1188" xmlns="http://www.w3.org/2000/svg">
<path class="svg-close-path" d="M1188 956q0 40-28 68l-136 136q-28 28-68 28t-68-28L594 866l-294 294q-28 28-68 28t-68-28L28 1024Q0 996 0 956t28-68l294-294L28 300Q0 272 0 232t28-68L164 28q28-28 68-28t68 28l294 294L888 28q28-28 68-28t68 28l136 136q28 28 28 68t-28 68L866 594l294 294q28 28 28 68z" fill="rgba(226, 241, 236, 0.85)" />
</svg>
</a>
<li>
<a class="nav__item" href="#">Home</a>
</li>
<li>
<a class="nav__item" href="#">Link</a>
</li>
<li>
<a class="nav__item" href="#">Second Link</a>
</li>
<li>
<a class="nav__item" href="#">Third Link</a>
</li>
<li>
<a class="nav__item" href="#last-section">Last Section</a>
</li>
</div>
<div class="nav__list-right">
<div class="page__overlay"></div>
</div>
</ul>
</nav>
</header>
<main>
<section>
<h1>Simply Navigation</h1>
<h4>Lightweight simple navigation built with flexbox and vanilla JavaScript</h4>
<h4>This is the stand-alone version - everything needed is in this file</h4>
<p>This is just a placeholder for an actual page, to show off this navigation component. This navigation solution is built entirely using Flexbox and vanilla JavaScript. Below are some key takeaways.</p>
<ul>
<li>No dependencies. Built using Flexbox & vanilla JavaScript only.</li>
<li>Fully responsive.</li>
<li>Mobile menu closes when selecting a link, try it. Open the mobile menu and click on the 'Last Section'</li>
<li>Easy close mobile menu is closable via entire top row and right side page overlay</li>
</ul>
<h3>Customizable</h3>
<ul>
<li>Breakpoint variable - default at 800px</li>
<li>Sticky navigation bar available</li>
<ul>
<li>Toggle <button>Sticky Nav</button> Sticky Nav is <span class="sticky-on-off"><strong>Off</strong></span></li>
<li>Note: Sticky navigation bar requires padding and/or margin on the parent or adjacent element. For example, on this page the adjacent <em>main</em> HTML element has a top margin of 6.5rem (nav height is 4.5rem) </li>
</ul>
</ul>
<h3>Another heading</h3>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Dignissimos, iure dolorem consequuntur tenetur quasi assumenda voluptas est quae doloremque praesentium error, vel itaque pariatur dolores.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. A natus deserunt quaerat assumenda explicabo! Explicabo placeat autem quod dolore! Ab molestias aliquam alias aut dolores quibusdam tempora qui velit rem dolorum, iusto deserunt architecto soluta aperiam voluptas perspiciatis excepturi saepe, et optio non. Sapiente, tenetur!</p>
<h3 id="last-section">Last heading</h3>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Distinctio sint doloribus eveniet voluptate molestias. Modi dicta expedita minima iusto ex eligendi, neque, ratione deleniti recusandae consectetur sunt! Id facere, autem consequuntur placeat minima odio ipsum nihil vel? Iusto dolorem aliquam adipisci aliquid magnam veniam, et nesciunt expedita placeat error praesentium?</p>
</section>
</main>
<script>
// This anonymous function can be inserted anywhere
// (eg. within a <script> tag or anywhere in an existing .js file or its own file)
(navDuty => {
const sideNav = document.getElementById('sideNav');
const closeNavBtn = document.querySelector('.closeBtn');
const toggleNavBtn = document.querySelector('.toggleNav');
const pageOverlay = document.querySelector('.page__overlay');
// Nav listeners
closeNavBtn.addEventListener('click', toggleNav);
toggleNavBtn.addEventListener('click', toggleNav);
pageOverlay.addEventListener('click', toggleNav);
// Nav funtion
function toggleNav() {
sideNav.classList.toggle('open');
};
// (on mobile) close nav menu when link is clicked
// this is useful on mobile when clicking an anchor tag on the current page (eg. index.html#last-section)
let navItems = document.querySelectorAll(".nav__item");
for (var i = 0; i < navItems.length; i++) {
navItems[i].addEventListener('click', function (event) {
toggleNav();
});
}
})();
//non related
(stickyNav => {
const button = document.querySelector('button');
const onOffHTML = document.querySelector('.sticky-on-off');
const on = '<strong>On</strong>';
const off = '<strong>Off</strong>';
const navWrapper = document.querySelector('.nav-wrapper');
button.addEventListener('click', toggleStickyNav => {
navWrapper.classList.toggle('sticky-nav');
(navWrapper.classList.contains('sticky-nav') ? onOffHTML.innerHTML = on : onOffHTML.innerHTML = off);
});
})();
</script>
</body>
</html>