質問編集履歴

1

foverをhoverに変更しました。classの共通化を行いCSSを短縮しました。

2019/04/08 05:56

投稿

aikawa
aikawa

スコア10

test CHANGED
@@ -1 +1 @@
1
- CSSのfover処理でボタンがうまく動かない
1
+ CSSのhover処理でボタンがうまく動かない
test CHANGED
@@ -52,17 +52,21 @@
52
52
 
53
53
  ```html
54
54
 
55
+ <div class="setting_div">
56
+
55
- <a href="#"><q class="Linkbutton_aaa">AAAAA</q></a>
57
+ <a href="#"><q class="Linkbutton aaa">aaaaaa</q></a>
56
-
58
+
57
- <a href="#"><q class="Linkbutton_bbb">BBBBB</q></a>
59
+ <a href="#"><q class="Linkbutton bbb">bbbbbb</q></a>
58
-
60
+
59
- <a href="#"><q class="Linkbutton_ccc">CCCCC</q></a>
61
+ <a href="#"><q class="Linkbutton ccc">cccccc</q></a>
60
-
62
+
61
- <a href="#"><q class="Linkbutton_ddd">DDDDD</q></a>
63
+ <a href="#"><q class="Linkbutton ddd">dddddd</q></a>
62
-
64
+
63
- <a href="#"><q class="Linkbutton_eee">EEEEE</q></a>
65
+ <a href="#"><q class="Linkbutton eee">eeeeee</q></a>
64
-
66
+
65
- <a href="#"><q class="Linkbutton_fff">FFFFF</q></a>
67
+ <a href="#"><q class="Linkbutton fff">ffffff</q></a>
68
+
69
+ </div>
66
70
 
67
71
  ```
68
72
 
@@ -72,17 +76,31 @@
72
76
 
73
77
  ```css
74
78
 
79
+ .setting_div{
80
+
81
+ float: left;
82
+
83
+ height: auto;
84
+
85
+ width: 30%;
86
+
87
+ margin: 10px;
88
+
75
- a{
89
+ }
90
+
91
+
92
+
76
-
93
+ .setting_div a{
94
+
77
- position: relative;
95
+ position: relative;
78
-
96
+
79
- color: rgb(0, 0, 0);
97
+ color: rgb(0, 0, 0);
80
-
98
+
81
- }
99
+ }
82
-
83
-
84
-
100
+
101
+
102
+
85
- .Linkbutton_aaa {
103
+ .setting_div .Linkbutton {
86
104
 
87
105
  display: flex;
88
106
 
@@ -110,19 +128,19 @@
110
128
 
111
129
  letter-spacing: 2px;
112
130
 
113
- transition: 1s box-shadow;
131
+ transition: 1s box-shadow;
114
-
132
+
115
- color: black;
133
+ color: black;
116
-
134
+
117
- }
135
+ }
118
-
136
+
119
- .Linkbutton_aaa:hover {
137
+ .setting_div .Linkbutton:hover {
120
138
 
121
139
  box-shadow: 0 5px 35px 0px rgba(0,0,0,.1);
122
140
 
123
141
  }
124
142
 
125
- .Linkbutton_aaa:hover:before, .Linkbutton_aaa:hover:after {
143
+ .setting_div .Linkbutton:hover:before, .Linkbutton:hover:after {
126
144
 
127
145
  display: block;
128
146
 
@@ -134,8 +152,6 @@
134
152
 
135
153
  height: 100px;
136
154
 
137
- background: rgb(255, 255, 255);
138
-
139
155
  border-radius: 75px;
140
156
 
141
157
  z-index: -1;
@@ -144,9 +160,7 @@
144
160
 
145
161
  }
146
162
 
147
- .Linkbutton_aaa:hover:after {
163
+ .setting_div .Linkbutton:hover:after {
148
-
149
- background: rgb(0, 0, 0);
150
164
 
151
165
  animation: 2s counterclockwise infinite;
152
166
 
@@ -154,363 +168,55 @@
154
168
 
155
169
 
156
170
 
157
- .Linkbutton_bbb {
158
-
159
- display: flex;
160
-
161
- align-items: center;
162
-
163
- justify-content: center;
164
-
165
- position: relative;
166
-
167
- margin: 20px auto;
168
-
169
- width: 250px;
170
-
171
- height: 100px;
172
-
173
- background: rgb(255, 255, 255,0.5);
174
-
175
- border-radius: 75px;
176
-
177
- font-family: 'Montserrat', sans-serif;
178
-
179
- font-size: 20px;
180
-
181
- font-weight: lighter;
182
-
183
- letter-spacing: 2px;
184
-
185
- transition: 1s box-shadow;
186
-
187
- color: black;
188
-
189
- }
190
-
191
- .Linkbutton_bbb:hover {
192
-
193
- box-shadow: 0 5px 35px 0px rgba(0,0,0,.1);
194
-
195
- }
196
-
197
- .Linkbutton_bbb:hover:before, .Linkbutton_bbb:hover:after {
198
-
199
- display: block;
200
-
201
- content: '';
202
-
203
- position: absolute;
204
-
205
- width: 250px;
206
-
207
- height: 100px;
208
-
209
- background: rgb(253, 143, 216);
210
-
211
- border-radius: 75px;
212
-
213
- z-index: -1;
214
-
215
- animation: 1s clockwise infinite;
216
-
217
- }
218
-
219
- .Linkbutton_bbb:hover:after {
220
-
221
- background: rgb(0, 0, 0);
222
-
223
- animation: 2s counterclockwise infinite;
224
-
225
- }
226
-
227
-
228
-
229
- .Linkbutton_ccc {
230
-
231
- display: flex;
232
-
233
- align-items: center;
234
-
235
- justify-content: center;
236
-
237
- position: relative;
238
-
239
- margin: 20px auto;
240
-
241
- width: 250px;
242
-
243
- height: 100px;
244
-
245
- background: rgb(255, 255, 255,0.5);
246
-
247
- border-radius: 75px;
248
-
249
- font-family: 'Montserrat', sans-serif;
250
-
251
- font-size: 20px;
252
-
253
- font-weight: lighter;
254
-
255
- letter-spacing: 2px;
256
-
257
- transition: 1s box-shadow;
258
-
259
- color: black;
260
-
261
- }
262
-
263
- .Linkbutton_ccc:hover {
264
-
265
- box-shadow: 0 5px 35px 0px rgba(0,0,0,.1);
266
-
267
- }
268
-
269
- .Linkbutton_ccc:hover:before, .Linkbutton_ccc:hover:after {
270
-
271
- display: block;
272
-
273
- content: '';
274
-
275
- position: absolute;
276
-
277
- width: 250px;
278
-
279
- height: 100px;
280
-
281
- background: rgb(167, 25, 250);
282
-
283
- border-radius: 75px;
284
-
285
- z-index: -1;
286
-
287
- animation: 1s clockwise infinite;
288
-
289
- }
290
-
291
- .Linkbutton_ccc:hover:after {
292
-
293
- background: rgb(0, 0, 0);
294
-
295
- animation: 2s counterclockwise infinite;
296
-
297
- }
298
-
299
-
300
-
301
- .Linkbutton_ddd {
302
-
303
- display: flex;
304
-
305
- align-items: center;
306
-
307
- justify-content: center;
308
-
309
- position: relative;
310
-
311
- margin: 20px auto;
312
-
313
- width: 250px;
314
-
315
- height: 100px;
316
-
317
- background: rgb(255, 255, 255,0.5);
318
-
319
- border-radius: 75px;
320
-
321
- font-family: 'Montserrat', sans-serif;
322
-
323
- font-size: 20px;
324
-
325
- font-weight: lighter;
326
-
327
- letter-spacing: 2px;
328
-
329
- transition: 1s box-shadow;
330
-
331
- color: black;
332
-
333
- }
334
-
335
- .Linkbutton_ddd:hover {
336
-
337
- box-shadow: 0 5px 35px 0px rgba(0,0,0,.1);
338
-
339
- }
340
-
341
- .Linkbutton_ddd:hover:before, .Linkbutton_ddd:hover:after {
342
-
343
- display: block;
344
-
345
- content: '';
346
-
347
- position: absolute;
348
-
349
- width: 250px;
350
-
351
- height: 100px;
352
-
353
- background: rgb(223, 143, 69);
354
-
355
- border-radius: 75px;
356
-
357
- z-index: -1;
358
-
359
- animation: 1s clockwise infinite;
360
-
361
- }
362
-
363
- .Linkbutton_ddd:hover:after {
364
-
365
- background: rgb(0, 0, 0);
366
-
367
- animation: 2s counterclockwise infinite;
368
-
369
- }
370
-
371
-
372
-
373
- .Linkbutton_eee {
374
-
375
- display: flex;
376
-
377
- align-items: center;
378
-
379
- justify-content: center;
380
-
381
- position: relative;
382
-
383
- margin: 20px auto;
384
-
385
- width: 250px;
386
-
387
- height: 100px;
388
-
389
- background: rgb(255, 255, 255,0.5);
390
-
391
- border-radius: 75px;
392
-
393
- font-family: 'Montserrat', sans-serif;
394
-
395
- font-size: 20px;
396
-
397
- font-weight: lighter;
398
-
399
- letter-spacing: 2px;
400
-
401
- transition: 1s box-shadow;
402
-
403
- color: black;
404
-
405
- }
406
-
407
- .Linkbutton_eee:hover {
408
-
409
- box-shadow: 0 5px 35px 0px rgba(0,0,0,.1);
410
-
411
- }
412
-
413
- .Linkbutton_eee:hover:before, .Linkbutton_eee:hover:after {
414
-
415
- display: block;
416
-
417
- content: '';
418
-
419
- position: absolute;
420
-
421
- width: 250px;
422
-
423
- height: 100px;
424
-
425
- background: rgb(237, 248, 79);
426
-
427
- border-radius: 75px;
428
-
429
- z-index: -1;
430
-
431
- animation: 1s clockwise infinite;
432
-
433
- }
434
-
435
- .Linkbutton_eee:hover:after {
436
-
437
- background: rgb(0, 0, 0);
438
-
439
- animation: 2s counterclockwise infinite;
440
-
441
- }
442
-
443
-
444
-
445
- .Linkbutton_fff {
446
-
447
- display: flex;
448
-
449
- align-items: center;
450
-
451
- justify-content: center;
452
-
453
- position: relative;
454
-
455
- margin: 20px auto;
456
-
457
- width: 250px;
458
-
459
- height: 100px;
460
-
461
- background: rgb(255, 255, 255,0.5);
462
-
463
- border-radius: 75px;
464
-
465
- font-family: 'Montserrat', sans-serif;
466
-
467
- font-size: 20px;
468
-
469
- font-weight: lighter;
470
-
471
- letter-spacing: 2px;
472
-
473
- transition: 1s box-shadow;
474
-
475
- color: black;
476
-
477
- }
478
-
479
- .Linkbutton_fff:hover {
480
-
481
- box-shadow: 0 5px 35px 0px rgba(0,0,0,.1);
482
-
483
- }
484
-
485
- .Linkbutton_fff:hover:before, .Linkbutton_fff:hover:after {
486
-
487
- display: block;
488
-
489
- content: '';
490
-
491
- position: absolute;
492
-
493
- width: 250px;
494
-
495
- height: 100px;
496
-
497
- background: rgb(128, 250, 209);
498
-
499
- border-radius: 75px;
500
-
501
- z-index: -1;
502
-
503
- animation: 1s clockwise infinite;
504
-
505
- }
506
-
507
- .Linkbutton_fff:hover:after {
508
-
509
- background: rgb(255, 255, 255);
510
-
511
- animation: 2s counterclockwise infinite;
512
-
513
- }
171
+ /* aaa */
172
+
173
+ .setting_div .aaa:hover:before, .aaa:hover:after {background: rgb(255, 255, 255);}
174
+
175
+ .setting_div .aaa:hover:after {background: rgb(0, 0, 0);}
176
+
177
+
178
+
179
+ /* bbb */
180
+
181
+ .setting_div .bbb:hover:before, .bbb:hover:after {background: rgb(253, 143, 216);}
182
+
183
+ .setting_div .bbb:hover:after {background: rgb(0, 0, 0);}
184
+
185
+
186
+
187
+ /* ccc */
188
+
189
+ .setting_div .ccc:hover:before, .ccc:hover:after {background: rgb(167, 25, 250);}
190
+
191
+ .setting_div .ccc:hover:after {background: rgb(0, 0, 0);}
192
+
193
+
194
+
195
+ /* ddd */
196
+
197
+ .setting_div .ddd:hover:before, .ddd:hover:after {background: rgb(223, 143, 69);}
198
+
199
+ .setting_div .ddd:hover:after {background: rgb(0, 0, 0);}
200
+
201
+
202
+
203
+ /* eee */
204
+
205
+ .setting_div .eee:hover:before, .eee:hover:after {background: rgb(237, 248, 79);}
206
+
207
+ .setting_div .eee:hover:after {background: rgb(0, 0, 0);}
208
+
209
+
210
+
211
+ /* fff */
212
+
213
+ .setting_div .fff:hover:before, .fff:hover:after {background: rgb(128, 250, 209);}
214
+
215
+ .setting_div .fff:hover:after {background: rgb(255, 255, 255);}
216
+
217
+
218
+
219
+
514
220
 
515
221
  @keyframes clockwise {
516
222
 
@@ -670,8 +376,6 @@
670
376
 
671
377
 
672
378
 
673
-
674
-
675
379
  ### 試したこと
676
380
 
677
381