teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

5

画像追加

2019/08/11 15:10

投稿

tahara777
tahara777

スコア6

title CHANGED
File without changes
body CHANGED
@@ -10,6 +10,10 @@
10
10
 
11
11
 
12
12
  ### 発生している問題・エラーメッセージ
13
+ ------pc画面------
14
+ ![pc画面](d51ef8bd9cad64024f2ae899848ac140.png)
15
+
16
+ ------スマホ画面------
13
17
  現在の表示
14
18
  ![現在の表示](909f96daf6bd973defaf6cb0cbf68c75.png)
15
19
 

4

文言修正

2019/08/11 15:10

投稿

tahara777
tahara777

スコア6

title CHANGED
File without changes
body CHANGED
@@ -10,7 +10,7 @@
10
10
 
11
11
 
12
12
  ### 発生している問題・エラーメッセージ
13
-
13
+ 現在の表示
14
14
  ![現在の表示](909f96daf6bd973defaf6cb0cbf68c75.png)
15
15
 
16
16
  下記のようにしたいのです。

3

コード修正

2019/08/11 15:06

投稿

tahara777
tahara777

スコア6

title CHANGED
File without changes
body CHANGED
@@ -108,7 +108,7 @@
108
108
  </body>
109
109
  </html>
110
110
  ```
111
- ```csss
111
+ ```css
112
112
  ****css***
113
113
  * {
114
114
  margin: 0;

2

コード編集

2019/08/11 15:04

投稿

tahara777
tahara777

スコア6

title CHANGED
File without changes
body CHANGED
@@ -17,7 +17,7 @@
17
17
  ![やりたいこと](9bdff23baf6265df101cca7b4c37a3e5.png)
18
18
 
19
19
  ### 該当のソースコード
20
-
20
+ ```html
21
21
  ****html****
22
22
  <!doctype html>
23
23
  <html>
@@ -107,7 +107,8 @@
107
107
  </script>
108
108
  </body>
109
109
  </html>
110
-
110
+ ```
111
+ ```csss
111
112
  ****css***
112
113
  * {
113
114
  margin: 0;
@@ -300,6 +301,9 @@
300
301
  }
301
302
 
302
303
 
304
+ ```
305
+
306
+
303
307
  ### 試したこと
304
308
 
305
309
  bodyタグに、contentsのクラス名を移動しました。

1

スクショ表示 コード書き込み

2019/08/11 15:03

投稿

tahara777
tahara777

スコア6

title CHANGED
File without changes
body CHANGED
@@ -11,16 +11,298 @@
11
11
 
12
12
  ### 発生している問題・エラーメッセージ
13
13
 
14
- 横並び並列メニューの上にロゴがあると、どう調整していいのかわかりません....。
14
+ ![現在表示](909f96daf6bd973defaf6cb0cbf68c75.png)
15
15
 
16
+ 下記のようにしたいのです。
17
+ ![やりたいこと](9bdff23baf6265df101cca7b4c37a3e5.png)
18
+
16
19
  ### 該当のソースコード
17
20
 
21
+ ****html****
22
+ <!doctype html>
23
+ <html>
24
+ <head>
25
+ <meta charset="utf-8">
26
+ <title>無題ドキュメント</title>
27
+ <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
28
+ <link rel="stylesheet" type="text/css" href="style.css">
29
+ </head>
30
+ <body id="contents">
31
+ <header>
32
+ <div class="headerinner">
33
+ <h1>タイトルタイトル</h1>
34
+ <div class="logoarea"> ロゴエリア </div>
35
+ </div>
36
+ </header>
37
+ <div id="wrapper">
38
+ <nav class="menu">
18
- なし
39
+ <ul>
40
+ <li><a href="#">MENU</a></li>
41
+ <li><a href="#">MENU</a></li>
42
+ <li><a href="#">MENU</a></li>
43
+ <li><a href="#">MENU</a></li>
44
+ <li><a href="#">MENU</a></li>
45
+ </ul>
46
+ </nav>
47
+ <button type="button" id="nav-btn" class="hamburger"> <span class="bdr"></span> <span class="bdr"></span> <span class="bdr"></span> </button>
48
+ <div>
49
+ <div class="flexbox">
50
+ <div class="item">テキストテキストテキストテキストテキストテキストテキストテキスト</div>
51
+ <div class="item">テキストテキストテキストテキストテキストテキストテキストテキスト</div>
52
+ <div class="item">テキストテキストテキストテキストテキストテキストテキストテキスト</div>
53
+ <div class="item">テキストテキストテキストテキストテキストテキストテキストテキスト</div>
54
+ <div class="item">テキストテキストテキストテキストテキストテキストテキストテキスト</div>
55
+ <div class="item">テキストテキストテキストテキストテキストテキストテキストテキスト</div>
56
+ </div>
57
+ </div>
58
+ </div>
59
+ <!-- wrapper -->
19
60
 
61
+ <footer> footer </footer>
62
+ <script type = "text/javascript">
63
+
64
+ (function () {
65
+
66
+ //ハンバーガーボタンクリック時の関数
67
+ //querySelector:CSSセレクタで要素を取得
68
+ const $hamburger = document.querySelector('.hamburger');
69
+ //addEventListener:イベント処理(click)
70
+ $hamburger.addEventListener('click', function(){
71
+ //ON時はis-activeクラス付与、OFF時はis-activeクラス削除
72
+ $hamburger.classList.toggle('is-active')
73
+ });
74
+
75
+ //全体を囲む要素をid[#wrapper]で指定
76
+ const $wrapper = document.getElementById('wrapper');
77
+ //メニューオープン・クローズのボタン要素をid[nav-btn]で指定
78
+ const $navBtn = document.getElementById('nav-btn');
79
+
80
+ //クリックしたら navToggle関数実行
81
+ $navBtn.addEventListener('click', navToggle);
82
+
83
+ //navToggleの関数
84
+ function navToggle() {
85
+ //contains:文字列が引数に指定した文字列を含まれているかどうか[nav-open]
86
+ if ($wrapper.classList.contains('nav-open')) {
87
+ //メニュークローズ時
88
+ navCloseFunc();
89
+ } else {
90
+ //メニューオープン時
91
+ navOpenFunc();
92
+ }
93
+ }
94
+
95
+ //メニューオープン時の関数
96
+ function navOpenFunc() {
97
+ //wrapperのclass[nav-open]付与
98
+ $wrapper.classList.add('nav-open');
99
+ }
100
+ //メニュークローズ時の関数
101
+ function navCloseFunc() {
102
+ //wrapperのclass[nav-open]削除
103
+ $wrapper.classList.remove('nav-open');
104
+ }
105
+
106
+ })();
107
+ </script>
108
+ </body>
109
+ </html>
110
+
111
+ ****css***
112
+ * {
113
+ margin: 0;
114
+ padding: 0;
115
+ }
116
+ li {
117
+ list-style: none;
118
+ }
119
+ a {
120
+ color: #000;
121
+ text-decoration: none;
122
+ }
123
+ h1 {
124
+ font-size: 0.5em;
125
+ }
126
+ #wrapper {
127
+ font-size: 1.2rem;
128
+ width: 100%;
129
+ text-align: center;
130
+ }
131
+ #contents {
132
+ transform: translateX(0);
133
+ transition: .4s transform;
134
+ }
135
+ #contents {
136
+ background-color: #fff;
137
+ }
138
+ #nav-btn {
139
+ display: none;
140
+ outline: none;
141
+ }
142
+ .menu ul {
143
+ display: flex;
144
+ justify-content: center;
145
+ align-items: center;
146
+ background: #5994FF;
147
+ }
148
+ .menu ul li {
149
+ padding: 0 20px;
150
+ transition: all .5s;
151
+ }
152
+ .menu ul li a {
153
+ position: relative;
154
+ display: inline-block;
155
+ text-decoration: none;
156
+ }
157
+ .menu ul li a:after {
158
+ position: absolute;
159
+ bottom: -4px;
160
+ left: 0;
161
+ content: '';
162
+ width: 100%;
163
+ height: 2px;
164
+ background: #333;
165
+ transform: scale(0, 1);
166
+ transform-origin: left top;
167
+ transition: transform .3s;
168
+ }
169
+ .menu ul li a:hover::after {
170
+ transform: scale(1, 1);
171
+ }
172
+
173
+ @media screen and (max-width: 768px) {
174
+ #nav-btn {
175
+ display: block;
176
+ position: fixed;
177
+ z-index: 11;
178
+ top: 10px;
179
+ right: 10px;
180
+ background: transparent;
181
+ border: none;
182
+ }
183
+ .hamburger {
184
+ position: relative;
185
+ display: block;
186
+ width: 50px;
187
+ height: 44px;
188
+ }
189
+ .hamburger .bdr {
190
+ position: absolute;
191
+ left: 0;
192
+ width: 100%;
193
+ height: 4px;
194
+ border-radius: 4px;
195
+ background: #000;
196
+ transition: all .5s;
197
+ }
198
+ .hamburger .bdr:nth-child(1) {
199
+ top: 0;
200
+ }
201
+ .hamburger .bdr:nth-child(2) {
202
+ top: 20px;
203
+ }
204
+ .hamburger .bdr:nth-child(3) {
205
+ bottom: 0;
206
+ }
207
+ .hamburger.is-active .bdr {
208
+ background: #000;
209
+ }
210
+ .hamburger.is-active .bdr:nth-child(1) {
211
+ transform: translateY(20px) rotate(-45deg);
212
+ }
213
+ .hamburger.is-active .bdr:nth-child(2) {
214
+ opacity: 0;
215
+ }
216
+ .hamburger.is-active .bdr:nth-child(3) {
217
+ transform: translateY(-20px) rotate(45deg);
218
+ }
219
+ .menu {
220
+ position: fixed;
221
+ top: 0;
222
+ right: 0;
223
+ width: 150px;
224
+ height: 100%;
225
+ padding-top: 70px;
226
+ text-align: left;
227
+ font-size: 13px;
228
+ background: #5994FF;
229
+ z-index: 1;
230
+ transform: translateX(150px);
231
+ transition: .4s all;
232
+ }
233
+ .menu ul {
234
+ display: block;
235
+ width: 150px;
236
+ line-height: 70px;
237
+ background: none;
238
+ color: #000;
239
+ text-align: center;
240
+ }
241
+ .menu ul li {
242
+ transition: all .5s;
243
+ }
244
+ .menu ul li:hover {
245
+ background: #fff;
246
+ }
247
+ .menu ul li a:after {
248
+ display: none;
249
+ }
250
+ .nav-open .menu {
251
+ transform: translateX(0);
252
+ }
253
+ .nav-open #contents {
254
+ transform: translateX(-150px);
255
+ }
256
+ }
257
+
258
+ @media screen and (min-width: 768px) {
259
+ nav.menu {
260
+ margin-bottom: 1.5em;
261
+ }
262
+ }
263
+ header {
264
+ margin-bottom: 1.5em;
265
+ }
266
+ .flexbox {
267
+ display: flex;
268
+ justify-content: space-between;
269
+ align-items: center;
270
+ flex-wrap: wrap;
271
+ max-width: 980px;
272
+ margin: 0 auto;
273
+ }
274
+ .headerinner {
275
+ max-width: 980px;
276
+ margin: 0 auto;
277
+ text-align: center;
278
+ }
279
+ .item {
280
+ width: 33%;
281
+ height: 200px;
282
+ background: #83C3FF;
283
+ display: block;
284
+ margin-bottom: 10px;
285
+ }
286
+ .logoarea {
287
+ width: 200px;
288
+ height: 66px;
289
+ color: #fff;
290
+ line-height: 66px;
291
+ background: #3D4490;
292
+ margin: 0 auto;
293
+ }
294
+ footer {
295
+ background: #3D4490;
296
+ color: #ffffff;
297
+ text-align: center;
298
+ padding: 1em;
299
+ margin-top: 1.5em;
300
+ }
301
+
302
+
20
303
  ### 試したこと
21
304
 
22
- 参考サイト(https://www.evoworx.co.jp/blog/drawer/)をみて実装するも、上にロゴがあるパターンではないので、
23
- HTMLCSS書き換えて挑戦てみたのですが、うくできませんでした。
305
+ bodyタグにcontentsのクラス名移動しました。
24
306
 
25
307
  ### 補足情報(FW/ツールのバージョンなど)
26
308