質問編集履歴
2
コードの掲載
test
CHANGED
File without changes
|
test
CHANGED
@@ -17,3 +17,479 @@
|
|
17
17
|
}
|
18
18
|
|
19
19
|
```
|
20
|
+
|
21
|
+
### 現段階の表示結果
|
22
|
+
|
23
|
+
現在、アイコンをタップするとハンバーガーメニューができる様にしているのですが、スクロールすると表示が切り替わる背景画像が、一番上に表示されている為、ハンバーガーメニューが表示されません。
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
### ハンバーガーメニューのコード
|
28
|
+
|
29
|
+
```html
|
30
|
+
|
31
|
+
header><link rel="stylesheet" type="text/css" href="ham-01.css">
|
32
|
+
|
33
|
+
<div id="nav-drawer">
|
34
|
+
|
35
|
+
<input id="nav-input" type="checkbox" class="nav-unshown">
|
36
|
+
|
37
|
+
<label id="nav-open" for="nav-input"><span></span></label>
|
38
|
+
|
39
|
+
<label class="nav-unshown" id="nav-close" for="nav-input"></label>
|
40
|
+
|
41
|
+
<div id="nav-content">
|
42
|
+
|
43
|
+
<a href="ev_index.html">HOME</a>
|
44
|
+
|
45
|
+
<a href="ev_exp.html">EVENT</a>
|
46
|
+
|
47
|
+
<a href="">POSTER</a>
|
48
|
+
|
49
|
+
<a href="ev_school.html">SCHOOL</a>
|
50
|
+
|
51
|
+
<a href="ev_access.html">ACCESS</a>
|
52
|
+
|
53
|
+
<a href="#">ABOUT THIS SITE</a>
|
54
|
+
|
55
|
+
</div>
|
56
|
+
|
57
|
+
</header>
|
58
|
+
|
59
|
+
```
|
60
|
+
|
61
|
+
```css
|
62
|
+
|
63
|
+
header {
|
64
|
+
|
65
|
+
padding:10px;
|
66
|
+
|
67
|
+
}
|
68
|
+
|
69
|
+
#nav-content a {
|
70
|
+
|
71
|
+
z-index: 30;
|
72
|
+
|
73
|
+
display: block;
|
74
|
+
|
75
|
+
text-align: center;
|
76
|
+
|
77
|
+
width: 80%;
|
78
|
+
|
79
|
+
max-width: 300px;
|
80
|
+
|
81
|
+
margin: 1rem auto;
|
82
|
+
|
83
|
+
padding: 0.5rem 0;
|
84
|
+
|
85
|
+
background: #777;
|
86
|
+
|
87
|
+
color: #fff;
|
88
|
+
|
89
|
+
font-famile: sans-serif;
|
90
|
+
|
91
|
+
text-decoration: none
|
92
|
+
|
93
|
+
}
|
94
|
+
|
95
|
+
#nav-drawer {
|
96
|
+
|
97
|
+
position: fixed;top: 0:left:0;
|
98
|
+
|
99
|
+
}
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
/*チェックボックス等は非表示に*/
|
104
|
+
|
105
|
+
.nav-unshown {
|
106
|
+
|
107
|
+
display:none;
|
108
|
+
|
109
|
+
}
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
/*アイコンのスペース*/
|
114
|
+
|
115
|
+
#nav-open {
|
116
|
+
|
117
|
+
display: inline-block;
|
118
|
+
|
119
|
+
width: 30px;
|
120
|
+
|
121
|
+
height: 22px;
|
122
|
+
|
123
|
+
vertical-align: middle;
|
124
|
+
|
125
|
+
}
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
/*ハンバーガーアイコンをCSSだけで表現*/
|
130
|
+
|
131
|
+
#nav-open span, #nav-open span:before, #nav-open span:after {
|
132
|
+
|
133
|
+
position: absolute;
|
134
|
+
|
135
|
+
height: 3px;/*線の太さ*/
|
136
|
+
|
137
|
+
width: 25px;/*長さ*/
|
138
|
+
|
139
|
+
border-radius: 3px;
|
140
|
+
|
141
|
+
background: #555;
|
142
|
+
|
143
|
+
display: block;
|
144
|
+
|
145
|
+
content: '';
|
146
|
+
|
147
|
+
cursor: pointer;
|
148
|
+
|
149
|
+
}
|
150
|
+
|
151
|
+
#nav-open span:before {
|
152
|
+
|
153
|
+
bottom: -8px;
|
154
|
+
|
155
|
+
}
|
156
|
+
|
157
|
+
#nav-open span:after {
|
158
|
+
|
159
|
+
bottom: -16px;
|
160
|
+
|
161
|
+
}
|
162
|
+
|
163
|
+
|
164
|
+
|
165
|
+
/*閉じる用の薄黒カバー*/
|
166
|
+
|
167
|
+
#nav-close {
|
168
|
+
|
169
|
+
display: none;/*はじめは隠しておく*/
|
170
|
+
|
171
|
+
position: fixed;
|
172
|
+
|
173
|
+
z-index: 99;
|
174
|
+
|
175
|
+
top: 0;/*全体に広がるように*/
|
176
|
+
|
177
|
+
left: 0;
|
178
|
+
|
179
|
+
width: 100%;
|
180
|
+
|
181
|
+
height: 100%;
|
182
|
+
|
183
|
+
background: black;
|
184
|
+
|
185
|
+
opacity: 0;
|
186
|
+
|
187
|
+
transition: .3s ease-in-out;
|
188
|
+
|
189
|
+
}
|
190
|
+
|
191
|
+
|
192
|
+
|
193
|
+
/*中身*/
|
194
|
+
|
195
|
+
#nav-content {
|
196
|
+
|
197
|
+
overflow: auto;
|
198
|
+
|
199
|
+
position: fixed;
|
200
|
+
|
201
|
+
top: 0;
|
202
|
+
|
203
|
+
left: 0;
|
204
|
+
|
205
|
+
z-index: 9999;/*最前面に*/
|
206
|
+
|
207
|
+
width: 90%;/*右側に隙間を作る(閉じるカバーを表示)*/
|
208
|
+
|
209
|
+
max-width: 330px;/*最大幅(調整してください)*/
|
210
|
+
|
211
|
+
height: 100%;
|
212
|
+
|
213
|
+
background: #333;/*背景色*/
|
214
|
+
|
215
|
+
transition: .3s ease-in-out;/*滑らかに表示*/
|
216
|
+
|
217
|
+
-webkit-transform: translateX(-105%);
|
218
|
+
|
219
|
+
transform: translateX(-105%);/*左に隠しておく*/
|
220
|
+
|
221
|
+
}
|
222
|
+
|
223
|
+
|
224
|
+
|
225
|
+
/*チェックが入ったらもろもろ表示*/
|
226
|
+
|
227
|
+
#nav-input:checked ~ #nav-close {
|
228
|
+
|
229
|
+
display: block;/*カバーを表示*/
|
230
|
+
|
231
|
+
opacity: .5;
|
232
|
+
|
233
|
+
}
|
234
|
+
|
235
|
+
|
236
|
+
|
237
|
+
#nav-input:checked ~ #nav-content {
|
238
|
+
|
239
|
+
-webkit-transform: translateX(0%);
|
240
|
+
|
241
|
+
transform: translateX(0%);/*中身を表示(右へスライド)*/
|
242
|
+
|
243
|
+
box-shadow: 6px 0 25px rgba(0,0,0,.15);
|
244
|
+
|
245
|
+
}
|
246
|
+
|
247
|
+
|
248
|
+
|
249
|
+
|
250
|
+
|
251
|
+
}
|
252
|
+
|
253
|
+
.site-header{
|
254
|
+
|
255
|
+
background: #fff;
|
256
|
+
|
257
|
+
display: flex;
|
258
|
+
|
259
|
+
padding: 60px 20px;
|
260
|
+
|
261
|
+
position: fixed;
|
262
|
+
|
263
|
+
justify-content: space-between;
|
264
|
+
|
265
|
+
width: 100%;
|
266
|
+
|
267
|
+
}
|
268
|
+
|
269
|
+
.site-logo img{
|
270
|
+
|
271
|
+
height: 20px;
|
272
|
+
|
273
|
+
width: auto;
|
274
|
+
|
275
|
+
}
|
276
|
+
|
277
|
+
.gnav__menu{
|
278
|
+
|
279
|
+
display: flex;
|
280
|
+
|
281
|
+
}
|
282
|
+
|
283
|
+
.gnav__menu__item{
|
284
|
+
|
285
|
+
margin-left: 20px;
|
286
|
+
|
287
|
+
}
|
288
|
+
|
289
|
+
.gnav__menu__item a{
|
290
|
+
|
291
|
+
color: #333;
|
292
|
+
|
293
|
+
text-decoration: none;
|
294
|
+
|
295
|
+
}
|
296
|
+
|
297
|
+
.hero{
|
298
|
+
|
299
|
+
max-height: 500px;
|
300
|
+
|
301
|
+
overflow: hidden;
|
302
|
+
|
303
|
+
}
|
304
|
+
|
305
|
+
.hero img{
|
306
|
+
|
307
|
+
height: auto;
|
308
|
+
|
309
|
+
width: 100%;
|
310
|
+
|
311
|
+
}
|
312
|
+
|
313
|
+
.content{
|
314
|
+
|
315
|
+
line-height: 1.6;
|
316
|
+
|
317
|
+
margin: 0 auto;
|
318
|
+
|
319
|
+
padding-top: 100px;
|
320
|
+
|
321
|
+
width: 800px;
|
322
|
+
|
323
|
+
}
|
324
|
+
|
325
|
+
.content p{
|
326
|
+
|
327
|
+
margin-bottom: 40px;
|
328
|
+
|
329
|
+
}
|
330
|
+
|
331
|
+
.site-footer{
|
332
|
+
|
333
|
+
background: #333;
|
334
|
+
|
335
|
+
padding: 80px 0;
|
336
|
+
|
337
|
+
}
|
338
|
+
|
339
|
+
.copyright{
|
340
|
+
|
341
|
+
color: #fff;
|
342
|
+
|
343
|
+
font-size: 12px;
|
344
|
+
|
345
|
+
text-align: center;
|
346
|
+
|
347
|
+
}
|
348
|
+
|
349
|
+
```
|
350
|
+
|
351
|
+
|
352
|
+
|
353
|
+
### 背景画像
|
354
|
+
|
355
|
+
|
356
|
+
|
357
|
+
```html
|
358
|
+
|
359
|
+
<div class="scroll-bg bg-color01" class="start">
|
360
|
+
|
361
|
+
<p style="background-color:#ffcc99;">説明文が入る</p>
|
362
|
+
|
363
|
+
</div>
|
364
|
+
|
365
|
+
<div class="fixed-bg bg01 sentence">
|
366
|
+
|
367
|
+
<p>タイトル</p>
|
368
|
+
|
369
|
+
</div>
|
370
|
+
|
371
|
+
|
372
|
+
|
373
|
+
<div class="scroll-bg bg-color01" class="start">
|
374
|
+
|
375
|
+
<p style="background-color:#ffcc99;">説明文が入る。</p>
|
376
|
+
|
377
|
+
</div>
|
378
|
+
|
379
|
+
|
380
|
+
|
381
|
+
<div class="fixed-bg bg02 sentence">
|
382
|
+
|
383
|
+
<p>タイトル</p>
|
384
|
+
|
385
|
+
</div>
|
386
|
+
|
387
|
+
|
388
|
+
|
389
|
+
<div class="scroll-bg bg-color02">
|
390
|
+
|
391
|
+
<p style="background-color:#ffcc99;">説明文が入る</p>
|
392
|
+
|
393
|
+
</div>
|
394
|
+
|
395
|
+
```
|
396
|
+
|
397
|
+
```css
|
398
|
+
|
399
|
+
.fixed-bg {
|
400
|
+
|
401
|
+
min-height: 100vh;
|
402
|
+
|
403
|
+
background-attachment: fixed;
|
404
|
+
|
405
|
+
background-size: cover;
|
406
|
+
|
407
|
+
background-position: center;
|
408
|
+
|
409
|
+
}
|
410
|
+
|
411
|
+
|
412
|
+
|
413
|
+
.bg01 {
|
414
|
+
|
415
|
+
background-image: url(170923.png);
|
416
|
+
|
417
|
+
/*background-size: contain; */
|
418
|
+
|
419
|
+
background-repeat: no-repeat;
|
420
|
+
|
421
|
+
background-size: cover;
|
422
|
+
|
423
|
+
}
|
424
|
+
|
425
|
+
|
426
|
+
|
427
|
+
.bg02 {
|
428
|
+
|
429
|
+
background-image: url(7211.png);
|
430
|
+
|
431
|
+
background-repeat: no-repeat;
|
432
|
+
|
433
|
+
background-size: cover;
|
434
|
+
|
435
|
+
}
|
436
|
+
|
437
|
+
|
438
|
+
|
439
|
+
.bg03 {
|
440
|
+
|
441
|
+
background-image: url(2377.png);
|
442
|
+
|
443
|
+
background-repeat: no-repeat;
|
444
|
+
|
445
|
+
background-size: cover;
|
446
|
+
|
447
|
+
}
|
448
|
+
|
449
|
+
|
450
|
+
|
451
|
+
.sentence{
|
452
|
+
|
453
|
+
position: relative;
|
454
|
+
|
455
|
+
}
|
456
|
+
|
457
|
+
|
458
|
+
|
459
|
+
.sentence p{
|
460
|
+
|
461
|
+
position: absolute;
|
462
|
+
|
463
|
+
top: 50%;
|
464
|
+
|
465
|
+
left: 50%;
|
466
|
+
|
467
|
+
-ms-transform: translate(-50%,-50%);
|
468
|
+
|
469
|
+
-webkit-transform: translate(-50%,-50%);
|
470
|
+
|
471
|
+
transform: translate(-50%,-50%);
|
472
|
+
|
473
|
+
margin:0;
|
474
|
+
|
475
|
+
padding:0;
|
476
|
+
|
477
|
+
color: white;/*文字は白に*/
|
478
|
+
|
479
|
+
font-weight: bold; /*太字に*/
|
480
|
+
|
481
|
+
font-size: 2em;/*サイズ2倍*/
|
482
|
+
|
483
|
+
font-family :Quicksand, sans-serif;/*Google Font*/
|
484
|
+
|
485
|
+
}
|
486
|
+
|
487
|
+
|
488
|
+
|
489
|
+
.sentence img{
|
490
|
+
|
491
|
+
width: 100%;
|
492
|
+
|
493
|
+
}
|
494
|
+
|
495
|
+
```
|
1
問題の具体的化
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
-
[参考にしたサイト](https://saruwakakun.com/html-css/basic/z-index)では、classを使って、
|
1
|
+
[参考にしたサイト](https://saruwakakun.com/html-css/basic/z-index)では、classを使って、z-indexの数字によって、大きい順に表示する様に設定しているのですが、classが多くすべてにz-indexをつけるのではなく、
|
2
|
+
|
3
|
+
一番上に表示されるのは、このclassという事は出来ないのでしょうか?
|
2
4
|
|
3
5
|
|
4
6
|
|