Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
380 lines (346 loc) · 17.5 KB

File metadata and controls

380 lines (346 loc) · 17.5 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta charset="UTF-8">
<title>JavaScript / jQuery</title>
<!-- <link rel="icon" type="image/x-icon" href="favicon.ico" /> favicon -->
<link href="https://fonts.googleapis.com/css?family=Bungee|Bungee+Shade|Open+Sans:400,700" rel="stylesheet"> <!-- fonts -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.6.3/css/font-awesome.min.css"> <!-- font-awesome -->
<link rel="stylesheet" text="text/css" href="styles/styles.css"> <!-- style page -->
<!--[if lt IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.min.js"></script>
<![endif]-->
</head>
<body>
<header>
<button class="menu">menu</button>
<h1>JAVASCRIPT / JQUERY</h1>
<nav class="site-nav-bar">
<ul>
<li><a href="index.html">Google Maps</a></li>
<li class="slide-out"><a class="slide-btn" href="#">Slide Show<i class="fa fa-chevron-right" aria-hidden="true" style="font-size: 16px; padding-left: 5px;"></i></a>
<ul class="step-menu">
<li><a class="scroll-step-01" href="#scroll-step-01">Step 01</a></li>
<li><a class="scroll-step-02" href="#scroll-step-02">Step 02</a></li>
<li><a class="scroll-step-03" href="#scroll-step-03">Step 03</a></li>
</ul>
</li>
<li><a href="tutorial-03.html">Snap to click</a></li>
</ul>
</nav>
</header> <!-- end header -->
<main>
<section class="step step-01">
<article class="show-01 show">
<h1>step 01</h1>
<h2>Grab some photos</h2>
<div class="slide-show">
<picture>
<img sizes="(max-width: 1340px) 100vw, 50vw"
srcset="
images/canyon_320.jpg 320w,
images/canyon_2005.jpg 2005w,
images/canyon_2996.jpg 2996w,
images/canyon_3776.jpg 3776w,
images/canyon_4200.jpg 4200w"
src="images/canyon_4200.jpg"
alt="Wide desert photo">
</picture>
</div>
</article>
<article class="tell-01 tell">
<h1><span id="scroll-step-01">&nbsp;</span>step 01</h1>
<h2>Grab some photos</h2>
<p>To begin you'll need a series of images. Size all the images to the same size. We'll eventually be overlapping the images. For smooth transitions between slides it's important that they all have a uniform height and width.</p>
<p>Need some images? Check out the following links to use the images from this tutorial:<br><a href="https://unsplash.com/search/desert?photo=eKpO8DlBvo0">image 01</a>
<a href="https://unsplash.com/search/desert?photo=ZDNr5nuZABg">image 02</a>
<a href="https://unsplash.com/search/desert?photo=VkZuNpXxdIg">image 03</a>
<a href="https://unsplash.com/search/desert?photo=eTa53Uf0StE">image 04</a></p>
<p>Now that you have your images gathered let's drop them into our HTML. In this tutorials we'll be passing the images into a list.</p>
<pre><code class="language-css">&lt;ul class="slide-show">
&lt;li>
&lt;img src="images/wide_desert.jpg" alt="Wide desert photo">
&lt;/li>
&lt;li>
&lt;img src="images/lake.jpg" alt="Red rocks and clear green lake">
&lt;/li>
&lt;li>
&lt;img src="images/rocks.jpg" alt="Canyon rocks">
&lt;/li>
&lt;li>
&lt;img src="images/desert_lake.jpg" alt="Desert lake">
&lt;/li>
&lt;/ul>
</code></pre>
</article>
</section>
<section class="step step-02">
<article class="show-02 show">
<h1>step 02</h1>
<h2>Applying some style</h2>
<div class="slide-show">
<ul>
<li class="slide">
<img sizes="(max-width: 1340px) 100vw, 50vw"
srcset="
images/canyon_320.jpg 320w,
images/canyon_2005.jpg 2005w,
images/canyon_2996.jpg 2996w,
images/canyon_3776.jpg 3776w,
images/canyon_4200.jpg 4200w"
src="images/canyon_4200.jpg"
alt="Wide desert photo">
<div class="dots">
<span class="dot on"></span>
<span class="dot"></span>
<span class="dot"></span>
<span class="dot"></span>
</div>
</li>
<li class="slide">
<img sizes="(max-width: 1340px) 100vw, 50vw"
srcset="
images/lake_320.jpg 320w,
images/lake_1393.jpg 1393w,
images/lake_2081.jpg 2081w,
images/lake_2665.jpg 2665w,
images/lake_2880.jpg 2880w"
src="images/lake_2880.jpg"
alt="Red rocks and clear green lake">
<div class="dots">
<span class="dot"></span>
<span class="dot on"></span>
<span class="dot"></span>
<span class="dot"></span>
</div>
</li>
<li class="slide">
<img sizes="(max-width: 1340px) 100vw, 50vw"
srcset="
images/rocks_320.jpg 320w,
images/rocks_1963.jpg 1963w,
images/rocks_2840.jpg 2840w,
images/rocks_3694.jpg 3694w,
images/rocks_4200.jpg 4200w"
src="images/rocks_4200.jpg"
alt="canyon rocks">
<div class="dots">
<span class="dot"></span>
<span class="dot"></span>
<span class="dot on"></span>
<span class="dot"></span>
</div>
</li>
<li class="slide">
<img sizes="(max-width: 1340px) 100vw, 50vw"
srcset="
images/desert_320.jpg 320w,
images/desert_2037.jpg 2037w,
images/desert_3034.jpg 3034w,
images/desert_3789.jpg 3789w,
images/desert_4200.jpg 4200w"
src="images/desert_4200.jpg"
alt="desert lake">
<div class="dots">
<span class="dot"></span>
<span class="dot"></span>
<span class="dot"></span>
<span class="dot on"></span>
</div>
</li>
</ul>
</div>
</article>
<article class="tell-02 tell">
<h1><span id="scroll-step-02">&nbsp;</span>step 02</h1>
<h2>Applying some style</h2>
<p>Good going, next let's make some of the fancy dots that so many slideshows seem to have. This will provide the slide show progress tracker of sorts for the user.</p>
<p>We'll be coding these dots. So let's begin by updating our HTML.</p>
<p>The 'dots' are being created using a series of spans. Notice that the div and the spans have been nested with in the &lt;li> elments. This will contain the dots and the iamges together. Assign a class of 'dots' to the parent &lt;div> and a class of 'dot' to each span. Add a secondary class of 'on' to the indicate the active slide.</p>
<pre><code class="language-css">&lt;ul class="slide-show">
&lt;li>
&lt;img src="images/wide_desert.jpg" alt="Wide desert photo">
&lt;div class="dots">
&lt;span class="dot on">&lt;/span>
&lt;span class="dot">&lt;/span>
&lt;span class="dot">&lt;/span>
&lt;span class="dot">&lt;/span>
&lt;/div>
&lt;/li>
&lt;li>
&lt;img src="images/lake.jpg" alt="Red rocks and clear green lake">
&lt;div class="dots">
&lt;span class="dot">&lt;/span>
&lt;span class="dot on">&lt;/span>
&lt;span class="dot">&lt;/span>
&lt;span class="dot">&lt;/span>
&lt;/div>
&lt;/li>
&lt;li>
&lt;img src="images/rocks.jpg" alt="Canyon rocks">
&lt;div class="dots">
&lt;span class="dot">&lt;/span>
&lt;span class="dot">&lt;/span>
&lt;span class="dot on">&lt;/span>
&lt;span class="dot">&lt;/span>
&lt;/div>
&lt;/li>
&lt;li>
&lt;img src="images/desert_lake.jpg" alt="Desert lake">
&lt;div class="dots">
&lt;span class="dot">&lt;/span>
&lt;span class="dot">&lt;/span>
&lt;span class="dot">&lt;/span>
&lt;span class="dot on">&lt;/span>
&lt;/div>
&lt;/li>
&lt;/ul>
</code></pre>
<p>Excellent, you've got your slide show all marked up. Next, let's apply some styles to it using CSS</p>
<p>Let's start with the &lt;ul> tag. The main take away here is to assign a relative position for the images to live in. Use the width and hieght properties to create the desired size and ratio of your slide show.</p>
<p> Now add in the &lt;li> tag. Use 'position: absolute'. Now all your list elements will be sitting on top of each other.</p>
<pre><code class="language-css">.slide-show {
position: relative;
margin: 50px auto;
width: 240px;
height: 240px;
padding: 10px;
}
li {
position: absolute;
}
</code></pre>
<p>Great, lastly we'll just need to style up those dots and we'll be good to go.</p>
<p>You can use 'transform: translate(0, -40px);' to overlap the dots onto the image.</p>
<pre><code class="language-css">.dots {
display: block;
float: left;
text-align: center;
width: 100%;
height: 20px;
transform: translate(0, -40px);
}
.dot {
display: inline-block;
height: 11px;
width: 11px;
margin: 0 2px;
border-radius: 50%;
background-color: transparent;
border: 2px solid white;
}
.on {
border: 2px solid white;
background-color: white;
}
</code></pre>
</article>
</section>
<section class="step step-03">
<article class="tutorial-02-show-03 show">
<h1>step 03</h1>
<h2>Putting it all together</h2>
<div class="slide-show">
<ul class="slider">
<li class="slide">
<img sizes="(max-width: 1340px) 100vw, 50vw"
srcset="
images/canyon_320.jpg 320w,
images/canyon_2005.jpg 2005w,
images/canyon_2996.jpg 2996w,
images/canyon_3776.jpg 3776w,
images/canyon_4200.jpg 4200w"
src="images/canyon_4200.jpg"
alt="Wide desert photo">
<div class="dots">
<span class="dot on"></span>
<span class="dot"></span>
<span class="dot"></span>
<span class="dot"></span>
</div>
</li>
<li class="slide">
<img sizes="(max-width: 1340px) 100vw, 50vw"
srcset="
images/lake_320.jpg 320w,
images/lake_1393.jpg 1393w,
images/lake_2081.jpg 2081w,
images/lake_2665.jpg 2665w,
images/lake_2880.jpg 2880w"
src="images/lake_2880.jpg"
alt="Red rocks and clear green lake">
<div class="dots">
<span class="dot"></span>
<span class="dot on"></span>
<span class="dot"></span>
<span class="dot"></span>
</div>
</li>
<li class="slide">
<img sizes="(max-width: 1340px) 100vw, 50vw"
srcset="
images/rocks_320.jpg 320w,
images/rocks_1963.jpg 1963w,
images/rocks_2840.jpg 2840w,
images/rocks_3694.jpg 3694w,
images/rocks_4200.jpg 4200w"
src="images/rocks_4200.jpg"
alt="canyon rocks">
<div class="dots">
<span class="dot"></span>
<span class="dot"></span>
<span class="dot on"></span>
<span class="dot"></span>
</div>
</li>
<li class="slide">
<img sizes="(max-width: 1340px) 100vw, 50vw"
srcset="
images/desert_320.jpg 320w,
images/desert_2037.jpg 2037w,
images/desert_3034.jpg 3034w,
images/desert_3789.jpg 3789w,
images/desert_4200.jpg 4200w"
src="images/desert_4200.jpg"
alt="desert lake">
<div class="dots">
<span class="dot"></span>
<span class="dot"></span>
<span class="dot"></span>
<span class="dot on"></span>
</div>
</li>
</ul>
</div>
</article>
<article class="tell-03 tell">
<h1><span id="scroll-step-03">&nbsp;</span>step 03</h1>
<h2>Putting it all together</h2>
<p>Alrighty, now that we've got our slide show marked up and styled we'll add functionality to it using a bit of jQuery. Our goal will be to create an automated slide show which plays on a loop. Each slide will fade into the next.</p>
<pre><code class="language-css">$(".slideshow > li:gt(0)").hide();
setInterval(function() {
$('.slide-show > li:first')
.fadeOut(1000)
.next()
.fadeIn(1000)
.end()
.appendTo('.slide-show');
}, 3000);
</code></pre>
<p>Let's break down this code piece by piece.</p>
<p>We're using the following line to hide all the image accept the first one. By default the image index begins at '0.' The line tells the browser to hide all list elements <a href="http://www.w3schools.com/jquery/sel_gt.asp">greater than</a> 0.</p>
<pre><code class="language-css">$(".slideshow > li:gt(0)").hide();</code></pre>
<p>Next, we're using a <a href="http://www.w3schools.com/jsref/met_win_setinterval.asp">setIterval</a> function too loop our slide show. The function begins by selecting the first list element, picture number 1. This image fades out and then fades in the the next image. The loop ends with a reset by using an .appendTo action.</p>
</article>
</section>
</main> <!-- end main -->
<footer></footer> <!-- end footer -->
<!-- scripts -->
<script src="scripts/jquery-3.1.1.min.js" type="text/javascript"></script>
<script src="scripts/prism.js" type="text/javascript"></script>
<script src="scripts/nav-effects.js" type="text/javascript"></script>
<!--<script src="scripts/follow-scroll.js" type="text/javascript"></script> -->
<script src="scripts/tutorial-02-slide-show.js" type="text/javascript"></script>
</body>
</html>
Morty Proxy This is a proxified and sanitized view of the page, visit original site.