質問編集履歴

1

<script><style>タグが一緒に記述してあり、大変失礼いたしました。一部修正しておりますので、大変お手数ですが再度ご確認お願い致します。

2019/08/19 05:13

投稿

OHIRA_web
OHIRA_web

スコア9

test CHANGED
File without changes
test CHANGED
@@ -12,7 +12,7 @@
12
12
 
13
13
  現在の動作状況は下記の流れになります。
14
14
 
15
- ハンバーガー開く→メニューを押す(ページ内リンク)→※スクロールするもののハンバーガメニューが閉じない
15
+ ハンバーガー開く→メニューを押す(ページ内リンク&SNSボタン)→※スクロールor新しいタブに移動するもののハンバーガメニューが閉じない
16
16
 
17
17
 
18
18
 
@@ -26,8 +26,6 @@
26
26
 
27
27
 
28
28
 
29
- jsは、参考サイトをコピーペーストしております。
30
-
31
29
  (参考サイト:https://saruwakakun.com/html-css/reference/nav-drawer)
32
30
 
33
31
 
@@ -38,6 +36,10 @@
38
36
 
39
37
 
40
38
 
39
+ 一部スムーススクロールの指示を記入しています。
40
+
41
+
42
+
41
43
  ### HTML
42
44
 
43
45
 
@@ -54,23 +56,29 @@
54
56
 
55
57
  <label id="nav-open" for="nav-input"><span></span></label>
56
58
 
57
- <label class="nav-unshown" id="nav-close" for="nav-input"></label>
59
+ <label class="nav-unshown" id="nav-close" for="nav-input">
60
+
58
-
61
+     </label>
62
+
63
+
64
+
59
- <div id="nav-content">
65
+ <div id="nav-content">
60
-
66
+
61
- <ul class="nav">
67
+ <ul class="nav">
68
+
69
+ <!--ページ内リンク&SNSボタン→下記URLクリックしてもハンバーガーメニュー閉じない-->
62
70
 
63
71
  <div class="sp_nav_inner">
64
72
 
65
- <li><a href="index.html#section02">テキスト</a></li>
73
+ <li><a href="#section02">テキスト</a></li>
66
-
74
+
67
- <li><a href="index.html#section03">テキスト</a></li>
75
+ <li><a href="#section03">テキスト</a></li>
68
-
76
+
69
- <li><a href="index.html#section04">テキスト</a></li>
77
+ <li><a href="#section04">テキスト</a></li>
70
-
78
+
71
- <li><a href="index.html#section05">テキスト</a></li>
79
+ <li><a href="#section05">テキスト</a></li>
72
-
80
+
73
-   <div class="sp_navsns">
81
+   <div class="sp_navsns">
74
82
 
75
83
  <li class="header_sns-item"><a href="#" target="_blank"><img src="img/icon_twitter.svg"></a></li>
76
84
 
@@ -82,16 +90,24 @@
82
90
 
83
91
  </div>
84
92
 
85
- </div>
93
+ </div>
86
-
94
+
87
- </ul>
95
+ </ul>
88
-
96
+
89
- </div>
97
+ </div>
90
-
98
+
91
- </div>
99
+ </div>
92
100
 
93
101
  </header>
94
102
 
103
+ <div id="#section02">テキスト</div>
104
+
105
+ <div id="#section03">テキスト</div>
106
+
107
+ <div id="#section04">テキスト</div>
108
+
109
+ <div id="#section05">テキスト</div>
110
+
95
111
 
96
112
 
97
113
  ```
@@ -104,17 +120,15 @@
104
120
 
105
121
  ```
106
122
 
123
+ <style type="text/css">
124
+
107
125
  header{
108
126
 
109
127
  width:100%;
110
128
 
111
- height:80px;
129
+ height:50px;
112
-
113
- }
130
+
114
-
115
-
116
-
117
- #nav-drawer {
131
+ background: green;
118
132
 
119
133
  }
120
134
 
@@ -136,13 +150,13 @@
136
150
 
137
151
  display: inline-block;
138
152
 
139
- width: 80px;
153
+ width: 50px;
140
-
154
+
141
- height: 80px;
155
+ height: 50px;
142
156
 
143
157
  vertical-align: middle;
144
158
 
145
-  background:#000000;
159
+  background:#9B2E8E;
146
160
 
147
161
  }
148
162
 
@@ -154,9 +168,9 @@
154
168
 
155
169
  position: absolute;
156
170
 
157
- height: 5px;/*線の太さ*/
171
+ height: 3px;/*線の太さ*/
158
-
172
+
159
- width: 41px;/*長さ*/
173
+ width: 29px;/*長さ*/
160
174
 
161
175
  background: #ffffff;
162
176
 
@@ -166,25 +180,29 @@
166
180
 
167
181
  cursor: pointer;
168
182
 
169
-  margin-top:23px;
183
+ margin-top:14px;
170
-
184
+
171
-  margin-left:23px;
185
+ margin-left:11px;
172
-
186
+
173
- }
187
+ }
188
+
189
+
174
190
 
175
191
  #nav-open span:before {
176
192
 
177
- bottom: -15px;
193
+ bottom: -10px;
178
-
194
+
179
-  left: -23px;
195
+  left: -11px;
180
-
196
+
181
- }
197
+ }
198
+
199
+
182
200
 
183
201
  #nav-open span:after {
184
202
 
185
- bottom: -30px;
203
+ bottom:-20px;
186
-
204
+
187
-  left:-23px;
205
+  left:-11px;
188
206
 
189
207
  }
190
208
 
@@ -222,40 +240,36 @@
222
240
 
223
241
  #nav-content {
224
242
 
225
- overflow: auto;
243
+ overflow: auto;
226
-
244
+
227
- position: fixed;
245
+ position: fixed;
228
-
246
+
229
- top: 0;
247
+ top: 0;
230
-
248
+
231
- left: 0;
249
+ left: 0;
232
-
250
+
233
- z-index: 9999;/*最前面に*/
251
+ z-index: 9999;/*最前面に*/
234
-
252
+
235
- width: 100vw;/*右側に隙間を作る(閉じるカバーを表示)*/
253
+ width: 100vw;/*右側に隙間を作る(閉じるカバーを表示)*/
236
-
254
+
237
- height: 100%;
255
+ height: 100%;
238
-
256
+
239
- background: #000000;/*背景色*/
257
+ background: #D14D98;/*背景色*/
240
-
258
+
241
- transition: .3s ease-in-out;/*滑らかに表示*/
259
+ transition: .3s ease-in-out;/*滑らかに表示*/
242
-
260
+
243
- -webkit-transform: translateX(-105%);
261
+ -webkit-transform: translateX(-105%);
244
-
262
+
245
- transform: translateX(375%);/*左に隠しておく*/
263
+ transform: translateX(375%);/*左に隠しておく*/
246
-
264
+
247
-  top:80px;
265
+ top:50px;
248
-
266
+
249
-  text-align: center;
267
+ text-align: center;
250
268
 
251
269
 
252
270
 
253
271
  }
254
272
 
255
- #nav-content ul{
256
-
257
- }
258
-
259
273
 
260
274
 
261
275
  .sp_nav_inner{
@@ -264,7 +278,7 @@
264
278
 
265
279
   height: 300px;
266
280
 
267
-  position: absolute;
281
+ position: absolute;
268
282
 
269
283
  top: 40%;
270
284
 
@@ -280,7 +294,7 @@
280
294
 
281
295
  .sp_nav_inner li{
282
296
 
283
-  padding-bottom: 50px;
297
+ padding-bottom: 50px;
284
298
 
285
299
  }
286
300
 
@@ -288,7 +302,7 @@
288
302
 
289
303
  #nav-content li a{
290
304
 
291
-  color: #ffffff;
305
+ color: #ffffff;
292
306
 
293
307
  }
294
308
 
@@ -296,27 +310,27 @@
296
310
 
297
311
  .sp_navsns{
298
312
 
299
-  display: flex;
313
+   display: flex;
300
-
314
+
301
-  justify-content: center;
315
+ justify-content: center;
302
-
316
+
303
- align-items: center;
317
+ align-items: center;
304
-
318
+
305
- }
319
+ }
306
-
307
-
320
+
321
+
308
322
 
309
323
  .sp_navsns a img{
310
324
 
311
- height: 23px;
325
+ height: 23px;
312
-
326
+
313
- opacity: 1;
327
+ opacity: 1;
314
-
328
+
315
- transform: opacity .3s;
329
+ transform: opacity .3s;
316
-
330
+
317
- }
331
+ }
318
-
319
-
332
+
333
+
320
334
 
321
335
  .sp_navsns a{
322
336
 
@@ -324,7 +338,7 @@
324
338
 
325
339
  }
326
340
 
327
-
341
+
328
342
 
329
343
  .sp_navsns a:last-child{
330
344
 
@@ -332,6 +346,8 @@
332
346
 
333
347
  }
334
348
 
349
+
350
+
335
351
 
336
352
 
337
353
  #nav-input:checked ~ #nav-content {
@@ -344,17 +360,27 @@
344
360
 
345
361
 
346
362
 
363
+ html{
364
+
365
+ scroll-behavior: smooth;
366
+
367
+ }
368
+
369
+
370
+
371
+ </style>
372
+
373
+
374
+
347
- ```
375
+ ```
348
-
349
-
350
-
351
- ### JS
376
+
352
-
353
-
354
-
355
-
356
-
377
+
378
+
379
+
380
+
357
- ```
381
+ ```
382
+
383
+ <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js?ver=1.8.3"></script>
358
384
 
359
385
  <script>
360
386
 
@@ -404,31 +430,11 @@
404
430
 
405
431
  </script>
406
432
 
407
- <style>
433
+
408
-
409
- html{
434
+
410
-
411
- scroll-behavior: smooth;
412
-
413
- }
414
-
415
- </style>
416
-
417
-
418
-
419
-
420
-
421
- ```
435
+ ```
422
-
423
-
424
-
425
- ### 試したこと
436
+
426
-
427
-
428
-
429
- 他サイトを参考にハンバーガーメニューがリンクを押すと同時に閉じるjsを入れてみましたが、
437
+
430
-
431
- どこのclass名・id名を入れるとよいのかわからず実装に成功することが出来ませんでした。
432
438
 
433
439
 
434
440