回答編集履歴

1

再質問につき修正

2019/10/19 11:28

投稿

naomi3
naomi3

スコア1105

test CHANGED
@@ -2,67 +2,43 @@
2
2
 
3
3
 
4
4
 
5
+ source mediaを指定する順番が違うようです。
6
+
5
7
  ```HTML
6
8
 
7
- <picture class="top_img bg">
9
+  <div class="top_img" id="top_img">
8
10
 
9
- <source media="(max-width: 1024px)" srcset="image/slider03.png">
11
+ <picture class="bg ">
10
12
 
11
- <img src="image/slider03.png">
13
+ <source media="(max-width: 580px)" srcset="img/kv_sp_1.jpg">
12
14
 
13
- </picture>
15
+ <source media="(max-width: 1024px)" srcset="image/slider03.png">
14
16
 
17
+ <img src="image/slider03.png">
15
18
 
19
+ </picture>
16
20
 
17
- <picture class="top_img bg bg_dn">
21
+ <picture class="bg bg_dn ">
18
22
 
19
- <source media="(max-width: 1024px)" srcset="image/download-1.jpg">
23
+ <source media="(max-width: 580px)" srcset="img/kv_sp_2.jpg">
20
24
 
21
- <img src="image/slider03.png">
25
+ <source media="(max-width: 1024px)" srcset="image/download-1.jpg ">
22
26
 
23
- </picture>
27
+ <img src="image/download-1.jpg ">
24
28
 
29
+ </picture>
25
30
 
31
+ <picture class="bg bg_dn ">
26
32
 
27
- <picture class="top_img bg bg_dn">
33
+ <source media="(max-width: 580px)" srcset="img/kv_sp_3.jpg">
28
34
 
29
- <source media="(max-width: 1024px)" srcset="image/download.jpg">
35
+ <source media="(max-width: 1024px)" srcset="image/download.jpg ">
30
36
 
31
- <img src="image/slider03.png">
37
+ <img src="image/download.jpg ">
32
38
 
33
- </picture>
39
+ </picture>
34
40
 
35
-
36
-
37
- <picture class="top_img bg">
38
-
39
- <source media="(max-width: 580px)" srcset="img/kv_sp_2.jpg">
40
-
41
- <img src="image/slider03.png">
42
-
43
- </picture>
41
+ </div>
44
-
45
-
46
-
47
- <picture class="top_img bg bg_dn">
48
-
49
- <source media="(max-width: 580px)" srcset="img/kv_sp_2.jpg">
50
-
51
- <img src="image/slider03.png">
52
-
53
- </picture>
54
-
55
-
56
-
57
- <picture class="top_img bg bg_dn">
58
-
59
- <source media="(max-width: 580px)" srcset="img/kv_sp_3.jpg">
60
-
61
- <img src="image/slider03.png">
62
-
63
- </picture>
64
-
65
-
66
42
 
67
43
  ```
68
44
 
@@ -70,20 +46,42 @@
70
46
 
71
47
  var count = 0;
72
48
 
73
- function slideshow()
49
+ function slideshow() {
74
50
 
75
- for (var i = 0; i < 6; i++) {
76
51
 
52
+
53
+ if (count % 2 == 0 && count % 3 == 2) {
54
+
55
+ $(".bg").eq(0).addClass("bg_dn");
56
+
77
- $(".bg").eq(i)[i % 3 == count ? 'removeClass' : 'addClass']("bg_dn");
57
+ $(".bg").eq(1).removeClass("bg_dn");
78
58
 
79
59
  }
80
60
 
61
+ else if (count % 2 == 0 && count % 3 == 1) {
62
+
63
+ $(".bg").eq(1).addClass("bg_dn");
64
+
65
+ $(".bg").eq(2).removeClass("bg_dn");
66
+
67
+ }
68
+
69
+ else if (count % 2 == 0 && count % 3 == 0) {
70
+
71
+ $(".bg").eq(2).addClass("bg_dn");
72
+
73
+ $(".bg").eq(0).removeClass("bg_dn");
74
+
75
+ }
76
+
77
+
78
+
81
79
  console.log(count);
82
80
 
83
- count = (count + 1) % 3;
81
+ count = (count + 1) % 6;
84
82
 
85
83
  }
86
84
 
87
- setInterval(slideshow, 4000);
85
+ setInterval(slideshow, 2000);
88
86
 
89
87
  ```