質問編集履歴
1
コードを追記しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -160,5 +160,134 @@
|
|
160
160
|
前回質問をして、いただいたコードを参考に自分なりにアレンジをしてみましたが、上手くいきませんでした。
|
161
161
|
お教え頂ければ幸いです。
|
162
162
|
|
163
|
-
###
|
163
|
+
### 追記しました。
|
164
|
+
|
165
|
+
```html、css、JavaScript
|
166
|
+
<meta name="robots" content="noindex,nofollow" />
|
167
|
+
<!doctype html>
|
168
|
+
<html lang="ja">
|
169
|
+
|
170
|
+
<head>
|
171
|
+
<meta charset="UTF-8" />
|
172
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
173
|
+
<link rel="stylesheet" href="https://plot-hub.com/code_example/lib/css/reset.css">
|
174
|
+
|
175
|
+
<style>
|
176
|
+
/*カテゴリーボタン*/
|
177
|
+
.button02 {
|
178
|
+
margin-left: 8rem;
|
179
|
+
/*transform: rotate(90deg);*/
|
180
|
+
}
|
181
|
+
.button_animation{
|
182
|
+
transform: rotate(90deg);
|
183
|
+
}
|
184
|
+
.button02 {
|
185
|
+
/* スタイル用 */
|
186
|
+
display: block;
|
187
|
+
width: 30px;
|
188
|
+
height: 30px;
|
189
|
+
border-radius: 50%;
|
190
|
+
border: 1px solid #00a0e9;
|
191
|
+
/* スタイル用 */
|
192
|
+
|
193
|
+
position: relative;
|
194
|
+
}
|
195
|
+
|
196
|
+
.button02:before,
|
197
|
+
.button02:after {
|
198
|
+
position: absolute;
|
199
|
+
content: '';
|
200
|
+
}
|
201
|
+
|
202
|
+
.button02:before {
|
203
|
+
top: 14px;
|
204
|
+
left: 6px;
|
205
|
+
width: 10px;
|
206
|
+
height: 1px;
|
207
|
+
background: #00a0e9;
|
208
|
+
}
|
209
|
+
.button02:after {
|
210
|
+
top: 11px;
|
211
|
+
left: 16px;
|
212
|
+
width: 0;
|
213
|
+
height: 0;
|
214
|
+
border-top: 4px solid transparent;
|
215
|
+
border-right: 0 solid transparent;
|
216
|
+
border-bottom: 0 solid transparent;
|
217
|
+
border-left: 5px solid #00a0e9;
|
218
|
+
}
|
219
|
+
.acd-check{
|
220
|
+
display: none;
|
221
|
+
}
|
222
|
+
|
223
|
+
.acd-label{
|
224
|
+
background: #e5f5fd;
|
225
|
+
margin-bottom: 1px;
|
226
|
+
padding: 10px;
|
227
|
+
display: flex;
|
228
|
+
justify-content: space-between;
|
229
|
+
}
|
230
|
+
.acd-content{
|
231
|
+
display: block;
|
232
|
+
height: 0;
|
233
|
+
opacity: 0;
|
234
|
+
padding: 0 10px;
|
235
|
+
transition: .5s;
|
236
|
+
visibility: hidden;
|
237
|
+
}
|
238
|
+
|
239
|
+
.acd-check:checked + .acd-label + .acd-content{
|
240
|
+
height: 50px;
|
241
|
+
opacity: 1;
|
242
|
+
padding: 10px;
|
243
|
+
visibility: visible;
|
244
|
+
}
|
245
|
+
.click1{ transform: rotate(270deg);transition: .5s;}
|
246
|
+
.click2{ transform: rotate(450deg);transition: .5s;}
|
247
|
+
</style>
|
248
|
+
|
249
|
+
</head>
|
250
|
+
|
251
|
+
<body>
|
252
|
+
<input id="acd-check1" class="acd-check" type="checkbox">
|
253
|
+
<label class="acd-label t-font25" for="acd-check1">クリックで開く1<i class="button02 button_animation"></i></label>
|
254
|
+
<div class="acd-content"><p>hello.world!</p></div>
|
255
|
+
|
256
|
+
<input id="acd-check2" class="acd-check" type="checkbox">
|
257
|
+
<label class="acd-label" for="acd-check2">クリックで開く2<i class="button02 button_animation"></i></label>
|
258
|
+
<div class="acd-content"><p>hello.world2!</p></div>
|
259
|
+
|
260
|
+
<input id="acd-check3" class="acd-check" type="checkbox">
|
261
|
+
<label class="acd-label" for="acd-check3">クリックで開く3</label>
|
262
|
+
<div class="acd-content"><p>hello.world3!</p></div>
|
263
|
+
|
264
|
+
<input id="acd-check4" class="acd-check" type="checkbox">
|
265
|
+
<label class="acd-label" for="acd-check4">クリックで開く4</label>
|
266
|
+
<div class="acd-content"><p>hello.world4!</p></div>
|
267
|
+
|
268
|
+
|
269
|
+
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
|
270
|
+
|
271
|
+
<script>
|
272
|
+
const a = document.querySelector(".button_animation");
|
273
|
+
document.addEventListener('click',e=>{
|
274
|
+
const t=e.target;
|
275
|
+
if(t.matches('.button_animation:not(.running)')){
|
276
|
+
t.classList.toggle('click1');
|
277
|
+
t.classList.toggle('click2',!t.classList.contains('click1'));
|
278
|
+
}
|
164
|
-
|
279
|
+
});
|
280
|
+
addEventListener("transitionstart", e=>{
|
281
|
+
const t=e.target;
|
282
|
+
t.classList.add('running');
|
283
|
+
});
|
284
|
+
document.addEventListener("transitionend",e=> {
|
285
|
+
const t=e.target;
|
286
|
+
t.classList.remove('running');
|
287
|
+
t.classList.remove('click2');
|
288
|
+
});
|
289
|
+
</script>
|
290
|
+
|
291
|
+
</body>
|
292
|
+
</html>
|
293
|
+
|