質問編集履歴
2
情報の修正・追記
title
CHANGED
|
@@ -1,1 +1,1 @@
|
|
|
1
|
-
|
|
1
|
+
スマホ向けレイアウトが崩れるので正常に表示させたい。
|
body
CHANGED
|
File without changes
|
1
情報の追記、修正
title
CHANGED
|
File without changes
|
body
CHANGED
|
@@ -1,14 +1,355 @@
|
|
|
1
1
|
### 前提・実現したいこと
|
|
2
|
+
【前提】
|
|
3
|
+
ProgateでHTML/CSSを学習中です。
|
|
4
|
+
現在、復習のためにProgateの演習で作成したサイトの模写コーディングを行っています。
|
|
5
|
+
・演習で作成したサイト→https://turkey505.github.io/yd/
|
|
2
6
|
|
|
7
|
+
上記URLの模写を行っています。
|
|
8
|
+
スマホ表示対応させようと演習の手順の記載通り”.btnのwidthを100%”に指定したところ、スマホ表示時のレイアウトが崩れてしまいます(登録ボタンが引き延ばされすぎて、ページ右側に余白ができる)。
|
|
3
|
-
|
|
9
|
+
演習の時点では.btnのwidthを100%に指定してもレイアウトが崩れることはありませんでした。
|
|
10
|
+
|
|
11
|
+
【問題解決のために試した事】
|
|
12
|
+
.btnのwidthを100%以下に指定すればページ右側の余白は解消しますが、それでは根本的な解決には至ってないと思われます。
|
|
13
|
+
|
|
14
|
+
【実現したいこと】
|
|
15
|
+
演習時点では上記で述べた現象が起きなかったが、模写コーディンングの時点で上記の現象が起き、困惑しています。演習の手順通りに作業を進めているのにこの様な現象が起きるのは何故でしょう?
|
|
16
|
+
そしてこの問題の解決策を教えて頂けますでしょうか?
|
|
17
|
+
|
|
4
|
-
↓イメージがResponsive.cssにて
|
|
18
|
+
↓イメージがResponsive.cssにて.btnのwidthを100%に指定した際のスマホ表示のページ。ボタンアイコン3つがトップ画像からはみ出し、右に余白が作られてしまい、レイアウトが崩れてしまう。
|
|
5
19
|

|
|
6
|
-
↓イメージの様に
|
|
20
|
+
↓イメージの様に登録ボタンの過剰な引き伸ばしを解消し、ページ右側に余白を作らずに正常な表示をさせたい
|
|
7
21
|

|
|
8
22
|
|
|
9
23
|
### 該当のソースコード
|
|
10
24
|
|
|
11
|
-
```
|
|
25
|
+
```
|
|
26
|
+
【index.html】
|
|
27
|
+
<!DOCTYPE html>
|
|
28
|
+
<html>
|
|
29
|
+
<head>
|
|
30
|
+
<meta charset="utf-8">
|
|
31
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
32
|
+
<title>Prog8</title>
|
|
33
|
+
<link rel="stylesheet" href="stylesheet.css">
|
|
34
|
+
<link rel="stylesheet" href="responsive.css">
|
|
35
|
+
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.15.1/css/all.css" integrity="sha384-vp86vTRFVJgpjF9jiIGPEEqYqlDwgyBgEF109VFjmqGmIY/Y4HV4d3Gp2irVfcrp" crossorigin="anonymous">
|
|
36
|
+
<script src="https://kit.fontawesome.com/e95c4cdf47.js" crossorigin="anonymous"></script>
|
|
37
|
+
</head>
|
|
38
|
+
|
|
39
|
+
<body>
|
|
40
|
+
<header>
|
|
41
|
+
<div class="container">
|
|
42
|
+
<div class="header-left">
|
|
43
|
+
<img class="logo" src="img/main_logo.png">
|
|
44
|
+
</div>
|
|
45
|
+
<span class="menu-icon"><i class="fa fa-bars"></i></span>
|
|
46
|
+
<div class="header-right">
|
|
47
|
+
<a href="#">レッスン</a>
|
|
48
|
+
<a href="#">新規登録</a>
|
|
49
|
+
<a href="#" class="login">ログイン</a>
|
|
50
|
+
</div>
|
|
51
|
+
</div>
|
|
52
|
+
</header>
|
|
53
|
+
|
|
54
|
+
<div class="top-wrapper">
|
|
55
|
+
<div class="container">
|
|
56
|
+
<h1>
|
|
57
|
+
LEARN TO CODE.
|
|
58
|
+
<br>
|
|
59
|
+
LEARN TO BE CREATIVE.
|
|
60
|
+
</h1>
|
|
61
|
+
<p>Progateはオンラインプログラミング学習サービスです。
|
|
62
|
+
<br>
|
|
63
|
+
初心者にもやさしいスライドとレッスンで、ウェブサービスを作りながらプログラミングを学んでいきましょう。</p>
|
|
64
|
+
<div class="btn-wrapper">
|
|
65
|
+
<a href="#" class="btn signup">
|
|
66
|
+
新規登録はこちら</a>
|
|
67
|
+
<p>or</p>
|
|
68
|
+
<a href="#" class="btn facebook">
|
|
69
|
+
<span class="fa fa-facebook"></span>
|
|
70
|
+
Facebookで登録
|
|
71
|
+
</a>
|
|
72
|
+
<a href="#" class="btn twitter">
|
|
73
|
+
<span class="fa fa-twitter">
|
|
74
|
+
Twitterで登録
|
|
75
|
+
</a>
|
|
76
|
+
</div>
|
|
77
|
+
</div>
|
|
78
|
+
</div>
|
|
79
|
+
|
|
80
|
+
<div class="lesson-wrapper">
|
|
81
|
+
<div class="container">
|
|
82
|
+
<div class="heading">
|
|
83
|
+
<h2>Learn Where to Get Started!</h2>
|
|
84
|
+
</div>
|
|
85
|
+
<div class="lessons">
|
|
86
|
+
<div class="lesson">
|
|
87
|
+
<div class="lesson-icon">
|
|
88
|
+
<img src="img/html.png">
|
|
89
|
+
<p>HTML&CSS</p>
|
|
90
|
+
</div>
|
|
91
|
+
<p class="text-contents">ウェブページの作成に使用される言語です。HTMLとCSSを組み合わせることで、静的なページを作り上げることができます。</p>
|
|
92
|
+
</div>
|
|
93
|
+
<div class="lesson">
|
|
94
|
+
<div class="lesson-icon">
|
|
95
|
+
<img src="img/jQuery.png">
|
|
96
|
+
<p>jQuery</p>
|
|
97
|
+
</div>
|
|
98
|
+
<p class="text-contents">素敵な動きを手軽に実装できるJavaScriptライブラリです。 アニメーション効果をつけたり、Ajax(エイジャックス)を使って外部ファイルを読み込んだりと色々なことができます。</p>
|
|
99
|
+
</div>
|
|
100
|
+
<div class="lesson">
|
|
101
|
+
<div class="lesson-icon">
|
|
102
|
+
<img src="img/ruby.png">
|
|
103
|
+
<p>Ruby</p>
|
|
104
|
+
</div>
|
|
105
|
+
<p class="text-contents">オープンソースの動的なプログラミング言語で、 シンプルさと高い生産性を備えています。大きなWebアプリケーションから小さな日用ツールまで、さまざまなソフトウェアを作ることができます。</p>
|
|
106
|
+
</div>
|
|
107
|
+
<div class="lesson">
|
|
108
|
+
<div class="lesson-icon">
|
|
109
|
+
<img src="img/php.png">
|
|
110
|
+
<p>PHP</p>
|
|
111
|
+
</div>
|
|
112
|
+
<p class="text-contents">HTMLだけではページの内容を変えることはできません。PHPはHTMLにプログラムを埋め込み、それを可能にします。</p>
|
|
113
|
+
</div>
|
|
114
|
+
</div>
|
|
115
|
+
</div>
|
|
116
|
+
</div>
|
|
117
|
+
|
|
118
|
+
<div class="message-wrapper">
|
|
119
|
+
<div class="container">
|
|
120
|
+
<div class="heading">
|
|
121
|
+
<h2>さぁ、あなたもProgateでプログラミングを学んでみませんか?</h2>
|
|
122
|
+
<h3>Let's learn to code, learn to be creative!</h3>
|
|
123
|
+
</div>
|
|
124
|
+
<span class="btn message">さっそく開発する</span>
|
|
125
|
+
</div>
|
|
126
|
+
</div>
|
|
127
|
+
|
|
128
|
+
<footer>
|
|
129
|
+
<div class="container">
|
|
130
|
+
<img src="img/footer_logo.png">
|
|
131
|
+
<p>Learn to Code, Learn to be Creative.</p>
|
|
132
|
+
</div>
|
|
133
|
+
</footer>
|
|
134
|
+
|
|
135
|
+
</body>
|
|
136
|
+
|
|
137
|
+
</html>
|
|
138
|
+
|
|
139
|
+
【stylesheet.css】
|
|
140
|
+
body {
|
|
141
|
+
margin: 0;
|
|
142
|
+
font-family: "Hiragino Kaku Gothic ProN";
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
a {
|
|
146
|
+
text-decoration: none;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
.container {
|
|
150
|
+
width: 100%;
|
|
151
|
+
margin: 0 auto;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
header {
|
|
155
|
+
height: 65px;
|
|
156
|
+
width: 100%;
|
|
157
|
+
background-color: rgba(34,49,52,0.9);
|
|
158
|
+
position: fixed;
|
|
159
|
+
top: 0;
|
|
160
|
+
z-index: 10;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
.logo {
|
|
164
|
+
width: 124px;
|
|
165
|
+
margin-top: 20px;
|
|
166
|
+
margin-left: 15px;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
.header-left {
|
|
170
|
+
float: left;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
.header-right {
|
|
174
|
+
float: right;
|
|
175
|
+
margin-left: 10px;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
.header-right a {
|
|
179
|
+
line-height: 65px;
|
|
180
|
+
padding: 0 25px;
|
|
181
|
+
color: white;
|
|
182
|
+
display: block;
|
|
183
|
+
float: left;
|
|
184
|
+
transition: all 0.5s;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
.header-right:hover {
|
|
188
|
+
background-color: rgba(255, 255, 255, 0.5);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
.menu-icon {
|
|
192
|
+
color: white;
|
|
193
|
+
float: right;
|
|
194
|
+
font-size: 25px;
|
|
195
|
+
padding: 21px 0;
|
|
196
|
+
display: none;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
.top-wrapper {
|
|
200
|
+
padding: 180px 0 100px 0;
|
|
201
|
+
background-image: url(img/top.png);
|
|
202
|
+
color: white;
|
|
203
|
+
background-size: cover;
|
|
204
|
+
text-align: center;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
.top-wrapper h1 {
|
|
208
|
+
opacity: 0.7;
|
|
209
|
+
font-size: 45px;
|
|
210
|
+
letter-spacing: 5px;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
.top-wrapper p {
|
|
214
|
+
opacity: 0.7;
|
|
215
|
+
font-size: 16px;
|
|
216
|
+
margin-bottom: 40px;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
.btn {
|
|
220
|
+
padding: 8px 24px;
|
|
221
|
+
color: white;
|
|
222
|
+
display: inline-block;
|
|
223
|
+
opacity: 0.8;
|
|
224
|
+
border-radius: 4px;
|
|
225
|
+
text-align: center;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
.signup {
|
|
229
|
+
background-color: #239b76;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
.btn-wrapper p {
|
|
233
|
+
margin-bottom: 20px;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
.facebook {
|
|
237
|
+
background-color: #3b5998;
|
|
238
|
+
margin-right: 10px;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
.twitter {
|
|
242
|
+
background-color: #55acee;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
.lesson-wrapper {
|
|
246
|
+
height: 580px;
|
|
247
|
+
padding-bottom: 80px;
|
|
248
|
+
padding-left: 5%;
|
|
249
|
+
padding-right: 5%;
|
|
250
|
+
background-color: #f7f7f7;
|
|
251
|
+
text-align: center;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
.heading {
|
|
255
|
+
padding-top: 80px;
|
|
256
|
+
padding-bottom: 50px;
|
|
257
|
+
color: #5f5d60;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
.heading h2 {
|
|
261
|
+
font-weight: normal;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
.lesson {
|
|
265
|
+
float: left;
|
|
266
|
+
width: 25%;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
.lesson-icon {
|
|
270
|
+
position: relative;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
.lesson-icon p {
|
|
274
|
+
position: absolute;
|
|
275
|
+
top: 37%;
|
|
276
|
+
width: 100%;
|
|
277
|
+
color: white;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
.text-contents {
|
|
281
|
+
width: 80%;
|
|
282
|
+
display: inline-block;
|
|
283
|
+
margin-top: 15px;
|
|
284
|
+
font-size: 13px;
|
|
285
|
+
color: #b3aeb5;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
.message-wrapper {
|
|
289
|
+
border-bottom: 1px solid #eee;
|
|
290
|
+
padding-bottom: 80px;
|
|
291
|
+
text-align: center;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
.heading {
|
|
295
|
+
padding-top: 80px;
|
|
296
|
+
padding-bottom: 50px;
|
|
297
|
+
color: #5f5d60;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
.heading h2 {
|
|
301
|
+
font-weight: normal;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
.heading h3 {
|
|
305
|
+
font-weight: normal;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
.message {
|
|
309
|
+
padding: 15px 40px;
|
|
310
|
+
background-color: #5dca88;
|
|
311
|
+
cursor: pointer;
|
|
312
|
+
box-shadow: 0px 7px #1a7940;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
.message:hover {
|
|
316
|
+
filter: brightness(1.10);
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
.message:active {
|
|
320
|
+
box-shadow: none;
|
|
321
|
+
position: relative;
|
|
322
|
+
top: 7px;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
footer {
|
|
326
|
+
padding-top: 30px;
|
|
327
|
+
padding-bottom: 20px;
|
|
328
|
+
margin-left: 15px;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
footer img {
|
|
332
|
+
width: 125px;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
footer p {
|
|
336
|
+
color: #b3aeb5;
|
|
337
|
+
font-size: 12px;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
【responsive.css】
|
|
341
|
+
/* tab */
|
|
342
|
+
@media (max-width: 1000px) {
|
|
343
|
+
.lesson-wrapper {
|
|
344
|
+
height: 990px;
|
|
345
|
+
}
|
|
346
|
+
.lesson {
|
|
347
|
+
width: 50%;
|
|
348
|
+
margin-bottom: 50px;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
/* sp */
|
|
12
353
|
@media (max-width: 670px) {
|
|
13
354
|
.lesson-wrapper {
|
|
14
355
|
height: 1700px;
|
|
@@ -23,6 +364,7 @@
|
|
|
23
364
|
width: 100%;
|
|
24
365
|
}
|
|
25
366
|
}
|
|
367
|
+
|
|
26
368
|
```
|
|
27
369
|
|
|
28
370
|
|