-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathindex.html
executable file
·419 lines (355 loc) · 14 KB
/
index.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
<!doctype html>
<html lang="en">
<head>
<title>Offcanvas</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale 1, user-scalable=no">
<link href="css/offcanvas.min.css" rel="stylesheet" type="text/css" media="screen">
<style>
/*
Box-sizing: border-box
======================
Credit: http://www.paulirish.com/2012/box-sizing-border-box-ftw/
*/
html {
box-sizing: border-box;
}
*,
*:before,
*:after {
box-sizing: inherit;
}
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen-Sans", "Ubuntu", "Cantarell", sans-serif;
font-size: 16px;
font-weight: 300;
line-height: 1.5;
}
.container {
max-width: 1000px;
margin: auto;
padding: 20px;
}
header {
margin: 0;
border-bottom: 4px solid #777;
}
h1 {
margin: 0;
font-size: 96px;
line-height: 1;
font-weight: 100;
}
@media (max-width: 767px) {
h1 {
font-size: 64px;
line-height: 1;
}
}
code {
display: inline-block;
border: 1px solid #ddd;
border-radius: 3px;
padding: 0 3px;
font-size: 16px;
color: #800;
background: #f6f6f6;
}
pre {
border: 1px solid #ddd;
border-radius: 3px;
padding: 10px;
font-size: 16px;
color: #800;
background: #f6f6f6;
overflow-y: auto;
}
.intro {
font-size: 1.5em;
line-height: 1.5;
}
.numbered-para {
padding: 6px 0 0 40px;
}
.number {
display: block;
float: left;
width: 35px;
height: 35px;
margin: -6px 0 0 -40px;
padding: 0;
font-size: 24px;
line-height: 35px;
text-align: center;
color: #fff;
background-color: #777;
border-radius: 50%;
}
footer {
margin-top: 72px;
border-top: 4px solid #777;
padding: 16px;
text-align: center;
}
</style>
</head>
<body>
<main id="page-wrap">
<div class="container">
<header>
<h1>Offcanvas</h1>
<h3 style="position: relative; margin-top: 0;"><i>Version 3.0</i><br />
<a href="https://github.com/SimonPadbury/Offcanvas">GitHub Repository</a></h3>
</header>
<p class="intro">Offcanvas is an easy-to-use, touch-enabled jQuery and SCSS off-canvas sidebar plugin with multiple options for configuration. It should be compatible with any CSS framework. The animations are all performed by CSS3.</p>
<h2>Features</h2>
<ul>
<li>Easy to use</li>
<li>Touch enabled</li>
<li>Tiny JS (<code>offcanvas.min.js</code>: 1 KB minified) <li>Tiny CSS (<code>offcanvas.min.css</code>: 2 KB minified)</li>
<li>SCSS included</li>
<li>Revealable 2<sup>nd</sup> level menus</li>
<li>Dismiss (totally reset) Offcanvas by click/tapping the navicon again or by click/tapping <i>anywhere outside</i> Offcanvas</li>
<li>Six configuration options (left/right × over/push/under)</li>
</ul>
<h2>Setup</h2>
<p class="numbered-para">
<span class="number">1</span> <b>The HTML can be as simple as in the following example.</b>
</p>
<pre><!doctype html>
<html>
<head>
...
<link href="<b>path/to/offcanvas.css</b>" rel="stylesheet" type="text/css" media="screen">
</head>
<body>
<mark><div id="offcanvas-sidebar"> ... </div></mark>
<mark><div id="page-wrap"> ... </div></mark>
<script src="<b>path/to/jquery.js</b>"></script>
<script src="<b>path/to/offcanvas.js</b>"></script>
</body>
</html></pre>
<p>
If you choose Offcanvas <b>over</b> options (see below), then the block <code>id="page-wrap"</code> is not necessary – it is only used for Offcanvas <b>push</b> or <b>under</b>, for enabling the page content to slide left or right.
</p>
<p>
The HTML order of <code>id="offcanvas-sidebar"</code> and <code>id="page-wrap"</code> is up to you – you choose, according to your own considerations (e.g. accessibility, and what your Offcanvas acrually contains).
</p>
<p class="numbered-para">
<span class="number">2</span> <b>Then, all you need to do is add your list of links</b> – and some headings if required.
</p>
<pre><mark><div id="offcanvas-sidebar"></mark>
<h4>Menu 1</h4> ⬅ <b>OPTIONAL</b>
<ul>
<li><a href="">Link 1.1</a>
<ul>
<li><a href="">Link 1.1.1</a></li>
<li><a href="">Link 1.1.2</a></li>
<li><a href="">Link 1.1.3</a></li>
<li><a href="">Link 1.1.4</a></li>
</ul>
</li>
<li><a href="">Link 1.2</a></li>
<li><a href="">Link 1.3</a></li>
<li><a href="">Link 1.4</a></li>
</ul>
<mark></div></mark></pre>
<p>
Your headings can also be links, if you need them to be. In that case, you can think of your Offcanvas as having three levels of menu links (parent, child and grandchild.)
</p>
<h2>Behaviour</h2>
<p class="numbered-para">
<span class="number">1</span> <b>Navicon</b>
</p>
<p>
The Offcanvas JS injects a <a href="http://www.transformicons.com">Transformicon</a>-style animated "hamburger" navicon and any Offcanvas Menus and back-links as required.
</p>
<p class="numbered-para">
<span class="number">2</span> <b>Fixed position</b>
</p>
<p>
The navicon is CSS <code>position:fixed</code> to the top-right or top-left corner of the window, depending on whether you configure a left or right Offcanvas.
</p>
<p>
Offcanvas is set to be <i>always available</i> by CSS <code>position:fixed</code> wherever your visitor activates it, from any scroll position on the webpage. And it resets to its starting scroll/ first-level menu state whenever a visitor dismisses it.
</p>
<p class="numbered-para">
<span class="number">3</span> <b>2<sup>nd</sup> level menu</b>
</p>
<p>
Offcanvas can display 2<sup>nd</sup> level menus (sub-menus). All you need to do is place an unordered list within the parent <code><li></code> and Offcanvas will handle everything.
</p>
<p>
The Offcanvas JS will insert a <code><span></code> containing <code>»</code> into the parent list item – visitors clicking this will see the Offvanvas sidebar slide to the left, revealing the child menu. And above the child menu the script will insert a <code><span></code> containing <code>« Back</code> – visitors clicking this will see the Offcanvas slide to the right, revealing the parent menu again.
</p>
<p class="numbered-para">
<span class="number">4</span> <b>Tap or click</b>
</p>
<p>
The Offcanvas JS will respond either to taps (using <code>touchstart()</code>) or clicks (using <code>click()</code>) depending on whichever pointing device your visitor uses.
</p>
<p class="numbered-para">
<span class="number">5</span> <b>Dismissable three ways</b>
</p>
<p>
When Offcanvas is opened (activated), it can be dismissed by eny of these three methods:
</p>
<ol>
<li>
By click/tapping the navicon again
</li>
<li>
By click/tapping <i>anywhere outside</i> Offcanvas i.e. anywhere on your content. (Since Offcanvas version 3, this is accomplished entirely by the JS script – not by click/tapping an overlay, as in earlier versions of Offcanvas.)
</li>
<li>
Changing the window-width (e.g. rotating a phone or tablet between portrait and landscape orientation) will also dismiss Offcanvas.
</li>
</ol>
<h2>Six sidebar options</h2>
<p>In the GitHub repository, <code>offvanvas.css</code> is demonstrating Offvanvass in "offcanvas-push-right" mode. But if you can configure the SCSS, then Offcanvas can have any one of six options.</p>
<p>Simply include one of mixins from <code>scss/import/_options.scss</code> in your <code>body</code> style rule, as in the following example.</p>
<pre>body {
@include offcanvas-push-right;
}</pre>
<p class="numbered-para">
<span class="number">1</span> <code>@include offcanvas-over-left</code> – the off-canvas sidebar slides in from the left on a layer over the webpage content.
</p>
<p class="numbered-para">
<span class="number">2</span> <code>@include offcanvas-over-right</code> – the off-canvas sidebar slides in from the right on a layer over the webpage content.
</p>
<p class="numbered-para">
<span class="number">3</span> <code>@include offcanvas-under-left</code> – the webpage content* slides right revealing the off-canvas sidebar to the left.
</p>
<p class="numbered-para">
<span class="number">4</span> <code>@include offcanvas-under-right</code> – the webpage content* slides left revealing the off-canvas sidebar to the right.
</p>
<p class="numbered-para">
<span class="number">5</span> <code>@include offcanvas-push-left</code> – the off-canvas sidebar slides in from the left, and the webpage content* slides right to accommodate it.
</p>
<p class="numbered-para">
<span class="number">6</span> <code>@include offcanvas-push-right</code> – the off-canvas sidebar slides in from the right, and the webpage content* slides left to accommodate it.
</p>
<p>
*For these four options, your webpage content must be wrapped as follows:
</p>
<pre>
<mark><div id="page-wrap"></mark>
<!-- Your webpage content -->
<mark></div></mark>
</pre>
<p>All these movements are performed by CSS3 transforms.</p>
<h2>Responsive or not – you choose</h2>
<p>No media queries have been set for Offcanvas. This is deliberate. It is up to you to set media queries as you choose (or not). You may choose to have Offcanvas to display and operate only for phones, or for tablets and phones, or for any size screen.</p>
<p>Simply set the Offcanvas components to <code>display: none</code> for the screen screen sizes where you don't require it, as in the following example.</p>
<pre>@media (min-width: 768px) {
#offcanvas-navicon,
#offcanvas-overlay,
#offcanvas-sidebar {
display: none
}
}</pre>
<footer>
<b>Offcanvas</b> <i>version 3.0</i> — <a href="https://github.com/SimonPadbury/Offcanvas">GitHub Repository</a>
</footer>
</div><!-- /.container -->
</main><!-- /#page-wrap -->
<section id="offcanvas-sidebar">
<div>
<h4>Menu 1</h4>
<ul>
<li><a href="#">Link 1.1</a>
<ul>
<li><a href="#">Link 1.1.1</a></li>
<li><a href="#">Link 1.1.2</a></li>
<li><a href="#">Link 1.1.3</a></li>
<li><a href="#">Link 1.1.4</a></li>
</ul>
</li>
<li><a href="#">Link 1.2</a></li>
<li><a href="#">Link 1.3</a></li>
<li><a href="#">Link 1.4</a></li>
</ul>
<h4>Menu 2</h4>
<ul>
<li><a href="#">Link 2.1</a></li>
<li><a href="#">Link 2.2</a></li>
<li><a href="#">Link 2.3</a></li>
<li><a href="#">Link 2.4</a>
<ul>
<li><a href="#">Link 2.4.1</a></li>
<li><a href="#">Link 2.4.2</a></li>
<li><a href="#">Link 2.4.3</a></li>
<li><a href="#">Link 2.4.4</a></li>
</ul>
</li>
</ul>
<h4>Menu 3</h4>
<ul>
<li><a href="#">Link 3.1</a></li>
<li><a href="#">Link 3.2</a></li>
<li><a href="#">Link 3.3</a></li>
<li><a href="#">Link 3.4</a></li>
</ul>
<h4>Menu 4</h4>
<ul>
<li><a href="#">Link 4.1</a></li>
<li><a href="#">Link 4.2</a></li>
<li><a href="#">Link 4.3</a></li>
<li><a href="#">Link 4.4</a></li>
</ul>
<h4>Menu 5</h4>
<ul>
<li><a href="#">Link 5.1</a></li>
<li><a href="#">Link 5.2</a></li>
<li><a href="#">Link 5.3</a></li>
<li><a href="#">Link 5.4</a></li>
</ul>
<h4>Menu 6</h4>
<ul>
<li><a href="#">Link 6.1</a>
<ul>
<li><a href="#">Link 6.1.1</a></li>
<li><a href="#">Link 6.1.2</a></li>
<li><a href="#">Link 6.1.3</a></li>
<li><a href="#">Link 6.1.4</a></li>
</ul>
</li>
<li><a href="#">Link 6.2</a></li>
<li><a href="#">Link 6.3</a></li>
<li><a href="#">Link 6.4</a></li>
</ul>
<h4>Menu 7</h4>
<ul>
<li><a href="#">Link 7.1</a></li>
<li><a href="#">Link 7.2</a></li>
<li><a href="#">Link 7.3</a></li>
<li><a href="#">Link 7.4</a></li>
</ul>
<h4>Menu 8</h4>
<ul>
<li><a href="#">Link 8.1</a></li>
<li><a href="#">Link 8.2</a></li>
<li><a href="#">Link 8.3</a></li>
<li><a href="#">Link 8.4</a></li>
</ul>
<h4>Menu 9</h4>
<ul>
<li><a href="#">Link 9.1</a></li>
<li><a href="#">Link 9.2</a></li>
<li><a href="#">Link 9.3</a></li>
<li><a href="#">Link 9.4</a></li>
</ul>
<h4>Menu 10</h4>
<ul>
<li><a href="#">Link 10.1</a></li>
<li><a href="#">Link 10.2</a></li>
<li><a href="#">Link 10.3</a></li>
<li><a href="#">Link 10.4</a></li>
</ul>
</div>
</section>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.3/jquery.min.js"></script>
<script src="js/offcanvas.min.js"></script>
</body>
</html>