質問編集履歴
1
修正、加筆 バツ印の部分をクッキリと黒色で表示させては仕様変更で取り消します。他、classListのコード作成について経緯を記しました。
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,5 +1,32 @@
|
|
1
|
-
ハンバーガーメニューが開いたときに、
|
1
|
+
レスポンシブデザインのハンバーガーメニューが開いたときに、Awsome Catch緑色の文字を黒に表示させようとしています。
|
2
|
-
|
2
|
+
classListを使っていますが上手く表示できません。
|
3
|
+
|
4
|
+
これまでの経緯。
|
5
|
+
|
6
|
+
レスポンシブデザインのハンバーガメニューの作成にあたって具体的トラブル箇所です。
|
7
|
+
|
8
|
+
HTML(コメント/Awsome Catch以下)では、id='catch_1"としています。
|
9
|
+
|
10
|
+
CSS(コメント/Awsome Catch以下)では、通常では、 #catch_1 h1 でAwsome Catchの文字色は緑色としています。
|
11
|
+
そして、classListを使用して、
|
12
|
+
|
13
|
+
メニューバーが開いたときに、**#catche_1を class="catch_1"として、文字を黒に表示させようとしました。**
|
14
|
+
|
15
|
+
そのため、
|
16
|
+
|
17
|
+
JavaScriptでは、var catch_1 = document.getElementById('catch_1');
|
18
|
+
として、id=catch_1を var catch_1としました。
|
19
|
+
|
20
|
+
そして、nav.addEventListener('click', function () {
|
21
|
+
catch_1.classList.toggle('catch_2');
|
22
|
+
});
|
23
|
+
として、classListを使って、id="chatch_1"をclass="catche_2"に変更させています。
|
24
|
+
予定では、CSSの .catch_2 h1 で文字色が黒になると想定していましたが、変化がありません。
|
25
|
+
|
26
|
+
addEventListenerのコード作成で、下記に問題があるかと検討つけていますが、対応しかねています。
|
27
|
+
var nav = document.getElementById('nav-wrapper');
|
28
|
+
var hamburger = document.getElementById('js-hamburger');
|
29
|
+
|
3
30
|
ご教示いただければ幸いです。
|
4
31
|
|
5
32
|
|
@@ -14,22 +41,15 @@
|
|
14
41
|
<meta charset="UTF-8">
|
15
42
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
16
43
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
17
|
-
|
18
|
-
<link rel="preconnect" href="https://fonts.googleapis.com">
|
19
|
-
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
20
|
-
<link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@700&display=swap" rel="stylesheet">
|
21
|
-
<link href="https://fonts.googleapis.com/css2?family=Montserrat&display=swap" rel="stylesheet">
|
22
|
-
<link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@700&display=swap" rel="stylesheet">
|
23
|
-
<link href="https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap" rel="stylesheet">
|
44
|
+
|
24
45
|
<link rel="stylesheet" href="style.css">
|
25
|
-
|
26
46
|
<!-- <link rel="stylesheet" href="reset.css"> -->
|
27
47
|
<script src="main.js"></script>
|
28
48
|
|
29
49
|
<title>MENTA</title>
|
50
|
+
|
30
51
|
</head>
|
31
52
|
|
32
|
-
<script src="https://cdn.jsdelivr.net/npm/vue@2.6.14/dist/vue.js"></script>
|
33
53
|
<body>
|
34
54
|
<div class="mainvisual" style="font-family: 'Montserrat'">
|
35
55
|
<header>
|
@@ -52,27 +72,27 @@
|
|
52
72
|
<li><a href="Blog.html">Blog</a></li>
|
53
73
|
<li><a href="Access.html">Access</a></li>
|
54
74
|
</ul>
|
55
|
-
</nav
|
75
|
+
</nav
|
56
76
|
</div>
|
77
|
+
|
78
|
+
|
57
79
|
</div>
|
58
80
|
</header>
|
59
|
-
|
81
|
+
<!------------> Awsome Catch ---------- -->
|
60
82
|
<div class="catch">
|
61
|
-
<div id="catch_1"
|
83
|
+
<div id="catch_1" >
|
62
84
|
<h1>Awesome<br>
|
63
85
|
Cosmetic</h1>
|
64
|
-
|
86
|
+
</div>
|
65
|
-
|
87
|
+
<!-- <p class="visivle_2" style="font-family: '游ゴシック体';">コスメのセレクトショップのサイトです。</p>
|
66
|
-
|
88
|
+
<p class="visible_2" style="font-family: '游ゴシック体';">コスメのセレクトショップのサイトです。</p> -->
|
67
|
-
|
68
89
|
</div>
|
69
|
-
|
90
|
+
|
70
91
|
</div>
|
71
92
|
|
72
93
|
|
73
94
|
</body>
|
74
95
|
</html>
|
75
|
-
|
76
96
|
```
|
77
97
|
|
78
98
|
|
@@ -122,106 +142,9 @@
|
|
122
142
|
}
|
123
143
|
}
|
124
144
|
|
125
|
-
|
126
|
-
|
127
|
-
/* ---------------------------- ヘッダーロゴ/ -------------------------*/
|
128
|
-
|
129
|
-
|
130
|
-
.header_logo {
|
131
|
-
position: absolute;
|
132
|
-
top:40px;
|
133
|
-
left:40px;
|
134
|
-
font-size: 20px;
|
135
|
-
}
|
136
|
-
|
137
|
-
|
138
|
-
@media screen and (max-width: 600px) {
|
139
|
-
.header_logo {
|
140
|
-
top:4.1%;
|
141
|
-
left:2%;
|
142
|
-
}
|
143
|
-
}
|
144
|
-
|
145
|
-
.header_logo p{
|
146
|
-
margin-top:5px;
|
147
|
-
font-size: 12px;
|
148
|
-
}
|
149
|
-
|
150
|
-
|
151
|
-
@media screen and (max-width: 600px) {
|
152
|
-
|
153
|
-
.header_logo p{
|
154
|
-
|
155
|
-
display: block;
|
156
|
-
}
|
157
|
-
}
|
158
|
-
|
159
|
-
|
160
|
-
|
161
145
|
/* ーーーーーーーーーーーーーーーーーー ヘッダーメニュー ーーーーーーーーーーーーーーーー */
|
162
146
|
|
163
147
|
|
164
|
-
.sp-nav ul {
|
165
|
-
position: absolute;
|
166
|
-
top:40px;
|
167
|
-
right:0;
|
168
|
-
display:flex;
|
169
|
-
color:white;
|
170
|
-
list-style: none;
|
171
|
-
padding:1px 45px;
|
172
|
-
justify-content:space-between;
|
173
|
-
}
|
174
|
-
|
175
|
-
|
176
|
-
@media screen and (max-width: 600px) {
|
177
|
-
.sp-nav ul {
|
178
|
-
position: relative;
|
179
|
-
display: flex;
|
180
|
-
flex-direction:column;
|
181
|
-
width:auto;
|
182
|
-
|
183
|
-
}
|
184
|
-
}
|
185
|
-
|
186
|
-
|
187
|
-
.sp-nav li a {
|
188
|
-
margin-right:50px;
|
189
|
-
color:white;
|
190
|
-
list-style: none;
|
191
|
-
font-size: 20px;
|
192
|
-
font-family: 'Montserrat', sans-serif;
|
193
|
-
z-index 4;
|
194
|
-
}
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
@media screen and (max-width: 600px) {
|
200
|
-
|
201
|
-
.sp-nav li a {
|
202
|
-
margin-right:50px;
|
203
|
-
padding:50px 0;
|
204
|
-
color:black;
|
205
|
-
list-style: none;
|
206
|
-
font-size: 30px;
|
207
|
-
font-family: 'Montserrat';
|
208
|
-
font-weight: 100;
|
209
|
-
margin-bottom: 38px;
|
210
|
-
margin-right: 150px;
|
211
|
-
z-index 4;
|
212
|
-
}
|
213
|
-
}
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
@media screen and (max-width: 600px) {
|
218
|
-
|
219
|
-
.sp-nav li {
|
220
|
-
padding-bottom: 60px;
|
221
|
-
}
|
222
|
-
}
|
223
|
-
|
224
|
-
|
225
148
|
/* -------------------------------- Awsome Catch ------------------------------*/
|
226
149
|
|
227
150
|
.catch h1 {
|
@@ -401,13 +324,13 @@
|
|
401
324
|
/* ----------------------------ハンバーガーがクリックされたら右からスライド ------------------*/
|
402
325
|
.open .sp-nav {
|
403
326
|
right: 0;
|
404
|
-
height: 730px;
|
327
|
+
height: 730px;
|
405
328
|
}
|
406
329
|
}
|
407
330
|
|
331
|
+
|
408
332
|
```
|
409
|
-
|
410
|
-
```
|
333
|
+
```Javascript
|
411
334
|
window.onload = function () {
|
412
335
|
// ナビゲーションバー
|
413
336
|
var nav = document.getElementById('nav-wrapper');
|