質問編集履歴
1
コードを追加しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -8,6 +8,80 @@
|
|
8
8
|
|
9
9
|
|
10
10
|
|
11
|
+
```HTML
|
12
|
+
|
13
|
+
<img id="slider" width="200" height="200" alt="slide">
|
14
|
+
|
15
|
+
```
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
```CSS
|
20
|
+
|
21
|
+
#slider {
|
22
|
+
|
23
|
+
opacity: 1;
|
24
|
+
|
25
|
+
transition: opacity 1s;
|
26
|
+
|
27
|
+
}
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
#slider.fadeOut {
|
32
|
+
|
33
|
+
opacity: 0;
|
34
|
+
|
35
|
+
}
|
36
|
+
|
37
|
+
```
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
```javascript
|
42
|
+
|
43
|
+
var imgArray = [
|
44
|
+
|
45
|
+
'https://images.unsplash.com/photo-1521673461164-de300ebcfb17?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=500&q=60',
|
46
|
+
|
47
|
+
'https://images.unsplash.com/photo-1497993950456-cdb57afd1cf1?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=500&q=60',
|
48
|
+
|
49
|
+
'https://images.unsplash.com/photo-1530281700549-e82e7bf110d6?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=500&q=60'],
|
50
|
+
|
51
|
+
curIndex = 0;
|
52
|
+
|
53
|
+
imgDuration = 3000;
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
function slideShow() {
|
58
|
+
|
59
|
+
document.getElementById('slider').className += "fadeOut";
|
60
|
+
|
61
|
+
setTimeout(function() {
|
62
|
+
|
63
|
+
document.getElementById('slider').src = imgArray[curIndex];
|
64
|
+
|
65
|
+
document.getElementById('slider').className = "";
|
66
|
+
|
67
|
+
},1000);
|
68
|
+
|
69
|
+
curIndex++;
|
70
|
+
|
71
|
+
if (curIndex == imgArray.length) { curIndex = 0; }
|
72
|
+
|
73
|
+
setTimeout(slideShow, imgDuration);
|
74
|
+
|
75
|
+
}
|
76
|
+
|
77
|
+
slideShow();
|
78
|
+
|
79
|
+
```
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
|
84
|
+
|
11
85
|
スライドショーを作るのにはこのウェブページの二つ目のコードを参考にしました。
|
12
86
|
|
13
87
|
https://stackoverflow.com/questions/25347946/add-fade-effect-in-slideshow-javascript
|