質問編集履歴
3
修正時間を追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -10,7 +10,7 @@
|
|
10
10
|
また、最終的な完成形は以下サイトのようなものを作成したいと思っています。
|
11
11
|
https://kiiro-d.com/
|
12
12
|
|
13
|
-
※2025/3/6 追記
|
13
|
+
※2025/3/6 12:00 追記
|
14
14
|
codepenではうまく動いているように見えたのですが、ローカルで確認すると同タイミングになっていたなかったので、コードを追記しました。
|
15
15
|
|
16
16
|
また、完成形のように1枚目から2枚目を表示する際、間隔を空けずに表示したいのですが、
|
2
コードを追記、説明の補足
test
CHANGED
File without changes
|
test
CHANGED
@@ -10,12 +10,220 @@
|
|
10
10
|
また、最終的な完成形は以下サイトのようなものを作成したいと思っています。
|
11
11
|
https://kiiro-d.com/
|
12
12
|
|
13
|
+
※2025/3/6 追記
|
14
|
+
codepenではうまく動いているように見えたのですが、ローカルで確認すると同タイミングになっていたなかったので、コードを追記しました。
|
15
|
+
|
16
|
+
また、完成形のように1枚目から2枚目を表示する際、間隔を空けずに表示したいのですが、
|
17
|
+
一瞬画像が消えてから次の画像が表示されてしまいます。
|
18
|
+
|
13
19
|
|
14
20
|
|
15
21
|
### 該当のソースコード
|
16
22
|
|
23
|
+
```html
|
24
|
+
<!DOCTYPE html>
|
25
|
+
<html lang="ja">
|
26
|
+
<head>
|
27
|
+
<meta charset="UTF-8">
|
28
|
+
<meta name="viewport" content="width=device-width">
|
29
|
+
<meta http-equiv="X-UA-Compatible" content="chrome=1">
|
30
|
+
<meta name="format-detection" content="telephone=no">
|
31
|
+
<meta name="description" content="">
|
32
|
+
<meta name="robots" content="index,follow">
|
33
|
+
<link rel="canonical" href="">
|
34
|
+
<title></title>
|
35
|
+
<link type="text/css" rel="stylesheet" href="css/top.css" media="all">
|
36
|
+
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js" ></script>
|
37
|
+
</head>
|
38
|
+
|
39
|
+
<body id="page">
|
40
|
+
|
41
|
+
<div class="pageWrap">
|
42
|
+
<div class="container">
|
43
|
+
<div class="page-content">
|
44
|
+
<div class="wrapper">
|
45
|
+
<div class="img-left">
|
46
|
+
<ul class="img-slide">
|
47
|
+
<li class="img-item">
|
48
|
+
<figure>
|
49
|
+
<img src="https://placehold.jp/d4d4d4/ffffff/1500x1100.png">
|
50
|
+
</figure>
|
51
|
+
</li>
|
52
|
+
<li class="img-item">
|
53
|
+
<figure>
|
54
|
+
<img src="https://placehold.jp/f1d5d5/ffffff/1500x1100.png">
|
55
|
+
</figure>
|
56
|
+
</li>
|
57
|
+
</ul>
|
58
|
+
</div>
|
59
|
+
<div class="img-right">
|
60
|
+
<ul class="img-slide">
|
61
|
+
<li class="img-item">
|
62
|
+
<figure>
|
63
|
+
<img src="https://placehold.jp/e0d5f1/ffffff/1500x1100.png">
|
64
|
+
</figure>
|
65
|
+
</li>
|
66
|
+
<li class="img-item">
|
67
|
+
<figure>
|
68
|
+
<img src="https://placehold.jp/d5e0f1/ffffff/1500x1100.png">
|
69
|
+
</figure>
|
70
|
+
</li>
|
71
|
+
</ul>
|
72
|
+
</div>
|
73
|
+
</div>
|
74
|
+
</div>
|
75
|
+
</div>
|
76
|
+
</div>
|
77
|
+
|
78
|
+
<script type="text/javascript" src="js/script.js" ></script>
|
79
|
+
|
80
|
+
</body>
|
81
|
+
</html>
|
82
|
+
|
17
83
|
```
|
84
|
+
|
85
|
+
```css
|
86
|
+
.wrapper {
|
87
|
+
display: flex;
|
88
|
+
flex-wrap: nowrap;
|
89
|
+
}
|
90
|
+
|
91
|
+
.img-left,
|
92
|
+
.img-right {
|
93
|
+
width: 50%;
|
94
|
+
height: 100vh;
|
95
|
+
overflow: hidden;
|
96
|
+
position: relative;
|
97
|
+
}
|
98
|
+
|
99
|
+
.img-slide {
|
100
|
+
position: absolute;
|
101
|
+
width: 100%;
|
102
|
+
height: 100%;
|
103
|
+
}
|
104
|
+
|
105
|
+
.img-item {
|
106
|
+
position: absolute;
|
107
|
+
width: 100%;
|
108
|
+
height: 100vh;
|
109
|
+
opacity: 0;
|
110
|
+
}
|
111
|
+
|
112
|
+
.img-item img {
|
113
|
+
width: 100%;
|
114
|
+
height: 100%;
|
115
|
+
object-fit: cover;
|
116
|
+
}
|
117
|
+
|
118
|
+
/* 左側のアニメーション(上から下へ) */
|
119
|
+
@keyframes anime_top_to_bottom {
|
18
|
-
|
120
|
+
0% {
|
121
|
+
clip-path: polygon(0% 0%, 100% 0%, 100% 0%, 0% 0%);
|
122
|
+
opacity: 1;
|
123
|
+
}
|
124
|
+
100% {
|
125
|
+
clip-path: polygon(0% 0%, 100% 0%, 100% 100%, 0% 100%);
|
126
|
+
opacity: 1;
|
127
|
+
}
|
128
|
+
}
|
129
|
+
|
130
|
+
/* 右側のアニメーション(下から上へ) */
|
131
|
+
@keyframes anime_bottom_to_top {
|
132
|
+
0% {
|
133
|
+
clip-path: polygon(0% 100%, 100% 100%, 100% 100%, 0% 100%);
|
134
|
+
opacity: 1;
|
135
|
+
}
|
136
|
+
100% {
|
137
|
+
clip-path: polygon(0% 0%, 100% 0%, 100% 100%, 0% 100%);
|
138
|
+
opacity: 1;
|
139
|
+
}
|
140
|
+
}
|
141
|
+
|
142
|
+
/* アニメーションクラス */
|
143
|
+
.animate-left {
|
144
|
+
animation: anime_top_to_bottom 2s ease-in-out forwards;
|
145
|
+
}
|
146
|
+
|
147
|
+
.animate-right {
|
148
|
+
animation: anime_bottom_to_top 2s ease-in-out forwards;
|
149
|
+
}
|
150
|
+
|
151
|
+
@media screen and (max-width: 959px){
|
152
|
+
.wrapper {
|
153
|
+
display: flex;
|
154
|
+
flex-wrap: nowrap;
|
155
|
+
flex-direction: column;
|
156
|
+
}
|
157
|
+
|
158
|
+
.img-left,
|
159
|
+
.img-right {
|
160
|
+
width: 100%;
|
161
|
+
height: 50vh;
|
162
|
+
}
|
163
|
+
|
164
|
+
/* 左側のアニメーション(上から下へ) */
|
165
|
+
@keyframes anime_top_to_bottom {
|
166
|
+
0% {
|
167
|
+
clip-path: polygon(0% 0%, 0% 0%, 0% 100%, 0% 100%);
|
168
|
+
}
|
169
|
+
100% {
|
170
|
+
clip-path: polygon(0% 0%, 100% 0%, 100% 100%, 0% 100%);
|
171
|
+
}
|
172
|
+
}
|
173
|
+
|
174
|
+
/* 右側のアニメーション(下から上へ) */
|
175
|
+
@keyframes anime_bottom_to_top {
|
176
|
+
0% {
|
177
|
+
clip-path: polygon(100% 0%, 100% 0%, 100% 100%, 100% 100%);
|
178
|
+
}
|
179
|
+
100% {
|
180
|
+
clip-path: polygon(0% 0%, 100% 0%, 100% 100%, 0% 100%);
|
181
|
+
opacity: 1;
|
182
|
+
}
|
183
|
+
}
|
184
|
+
}
|
185
|
+
|
186
|
+
|
187
|
+
```
|
188
|
+
|
189
|
+
```jQuery
|
190
|
+
$(function(){
|
191
|
+
$(document).ready(function () {
|
192
|
+
function startAnimation(leftSelector, rightSelector) {
|
193
|
+
let leftItems = $(leftSelector).find(".img-item");
|
194
|
+
let rightItems = $(rightSelector).find(".img-item");
|
195
|
+
let index = 0;
|
196
|
+
let animationDuration = 2000; // アニメーション時間 (2秒)
|
197
|
+
let intervalTime = 4000; // 画像切り替え間隔 (4秒)
|
198
|
+
|
199
|
+
function animateNext() {
|
200
|
+
let nextIndex = (index + 1) % leftItems.length;
|
201
|
+
|
202
|
+
// すべての画像を非表示(アニメーションをリセット)
|
203
|
+
leftItems.css({ opacity: 0 }).removeClass("animate-left");
|
204
|
+
rightItems.css({ opacity: 0 }).removeClass("animate-right");
|
205
|
+
|
206
|
+
// **左右の画像を完全に同時に表示&アニメーション**
|
207
|
+
leftItems.eq(nextIndex).css({ opacity: 1 }).addClass("animate-left");
|
208
|
+
rightItems.eq(nextIndex).css({ opacity: 1 }).addClass("animate-right");
|
209
|
+
|
210
|
+
index = nextIndex;
|
211
|
+
}
|
212
|
+
|
213
|
+
// 初回実行
|
214
|
+
animateNext();
|
215
|
+
|
216
|
+
// **左右のアニメーションを完全に同期**
|
217
|
+
setInterval(animateNext, intervalTime);
|
218
|
+
}
|
219
|
+
|
220
|
+
// **左右のアニメーションを同時に開始**
|
221
|
+
startAnimation(".img-left", ".img-right");
|
222
|
+
});
|
223
|
+
});
|
224
|
+
|
225
|
+
|
226
|
+
|
19
227
|
```
|
20
228
|
|
21
229
|
### 試したこと・調べたこと
|
1
リンク切れを修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -5,10 +5,10 @@
|
|
5
5
|
大まかなアニメーションの作成はできたのですが、どうしても左側の画像を表示した後に右側のアニメーションが開始されてしまいます。
|
6
6
|
codepenでコードを書きましたので、ご確認ください。
|
7
7
|
|
8
|
-
|
8
|
+
https://codepen.io/k_2024/pen/YPzVRwW
|
9
9
|
|
10
10
|
また、最終的な完成形は以下サイトのようなものを作成したいと思っています。
|
11
|
-
|
11
|
+
https://kiiro-d.com/
|
12
12
|
|
13
13
|
|
14
14
|
|