質問編集履歴

2

情報の修正・追記

2020/11/30 03:09

投稿

_505turkish
_505turkish

スコア6

test CHANGED
@@ -1 +1 @@
1
- 【responsive.css】レイアウトが崩れてしまうので正常表示させたい。
1
+ スマホ向けレイアウトが崩れので正常表示させたい。
test CHANGED
File without changes

1

情報の追記、修正

2020/11/30 03:09

投稿

_505turkish
_505turkish

スコア6

test CHANGED
File without changes
test CHANGED
@@ -1,14 +1,42 @@
1
1
  ### 前提・実現したいこと
2
2
 
3
-
3
+ 【前提】
4
+
4
-
5
+ ProgateでHTML/CSSを学習中です。
6
+
5
- HTML/CSSてスマホ表示対応のサイトの模写コーディングを行っています。
7
+ 現在、復習のためProgate演習で作成したサイトの模写コーディングを行っています。
8
+
6
-
9
+ ・演習で作成したサイト→https://turkey505.github.io/yd/
10
+
11
+
12
+
13
+ 上記URLの模写を行っています。
14
+
15
+ スマホ表示対応させようと演習の手順の記載通り”.btnのwidthを100%”に指定したところ、スマホ表示時のレイアウトが崩れてしまいます(登録ボタンが引き延ばされすぎて、ページ右側に余白ができる)。
16
+
17
+ 演習の時点では.btnのwidthを100%に指定してもレイアウトが崩れることはありませんでした。
18
+
19
+
20
+
21
+ 【問題解決のために試した事】
22
+
23
+ .btnのwidthを100%以下に指定すればページ右側の余白は解消しますが、それでは根本的な解決には至ってないと思われます。
24
+
25
+
26
+
27
+ 【実現したいこと】
28
+
29
+ 演習時点では上記で述べた現象が起きなかったが、模写コーディンングの時点で上記の現象が起き、困惑しています。演習の手順通りに作業を進めているのにこの様な現象が起きるのは何故でしょう?
30
+
31
+ そしてこの問題の解決策を教えて頂けますでしょうか?
32
+
33
+
34
+
7
- ↓イメージがResponsive.cssにてボタン定した際のスマホ表示のページです。ボタンアイコン3つがトップ画像からはみ出し、右に余白が作られてしまい、レイアウトが崩れてしまいます
35
+ ↓イメージがResponsive.cssにて.btnwidth100%に指定した際のスマホ表示のページ。ボタンアイコン3つがトップ画像からはみ出し、右に余白が作られてしまい、レイアウトが崩れてしま
8
36
 
9
37
  ![誤表示](5bd1b58258e30338e952b632b347d11b.png)
10
38
 
11
- ↓イメージの様にレイアウト崩れを解消し、ボタントップ画像収めつつアイコンの幅広げるにはどうすれば良でしょうか?
39
+ ↓イメージの様に登録ボタン過剰な引き伸ばしを解消し、ページ右側に余白作らず正常な表示させた
12
40
 
13
41
  ![正常な表示](35b41cd092a35139881f7b91dddf038f.png)
14
42
 
@@ -18,7 +46,661 @@
18
46
 
19
47
 
20
48
 
21
- ```【responsive.css】
49
+ ```
50
+
51
+ 【index.html】
52
+
53
+ <!DOCTYPE html>
54
+
55
+ <html>
56
+
57
+ <head>
58
+
59
+ <meta charset="utf-8">
60
+
61
+ <meta name="viewport" content="width=device-width,initial-scale=1">
62
+
63
+ <title>Prog8</title>
64
+
65
+ <link rel="stylesheet" href="stylesheet.css">
66
+
67
+ <link rel="stylesheet" href="responsive.css">
68
+
69
+ <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.15.1/css/all.css" integrity="sha384-vp86vTRFVJgpjF9jiIGPEEqYqlDwgyBgEF109VFjmqGmIY/Y4HV4d3Gp2irVfcrp" crossorigin="anonymous">
70
+
71
+ <script src="https://kit.fontawesome.com/e95c4cdf47.js" crossorigin="anonymous"></script>
72
+
73
+ </head>
74
+
75
+
76
+
77
+ <body>
78
+
79
+ <header>
80
+
81
+ <div class="container">
82
+
83
+ <div class="header-left">
84
+
85
+ <img class="logo" src="img/main_logo.png">
86
+
87
+ </div>
88
+
89
+ <span class="menu-icon"><i class="fa fa-bars"></i></span>
90
+
91
+ <div class="header-right">
92
+
93
+ <a href="#">レッスン</a>
94
+
95
+ <a href="#">新規登録</a>
96
+
97
+ <a href="#" class="login">ログイン</a>
98
+
99
+ </div>
100
+
101
+ </div>
102
+
103
+ </header>
104
+
105
+
106
+
107
+ <div class="top-wrapper">
108
+
109
+ <div class="container">
110
+
111
+ <h1>
112
+
113
+ LEARN TO CODE.
114
+
115
+ <br>
116
+
117
+ LEARN TO BE CREATIVE.
118
+
119
+ </h1>
120
+
121
+ <p>Progateはオンラインプログラミング学習サービスです。
122
+
123
+ <br>
124
+
125
+ 初心者にもやさしいスライドとレッスンで、ウェブサービスを作りながらプログラミングを学んでいきましょう。</p>
126
+
127
+ <div class="btn-wrapper">
128
+
129
+ <a href="#" class="btn signup">
130
+
131
+ 新規登録はこちら</a>
132
+
133
+ <p>or</p>
134
+
135
+ <a href="#" class="btn facebook">
136
+
137
+ <span class="fa fa-facebook"></span>
138
+
139
+ Facebookで登録
140
+
141
+ </a>
142
+
143
+ <a href="#" class="btn twitter">
144
+
145
+ <span class="fa fa-twitter">
146
+
147
+ Twitterで登録
148
+
149
+ </a>
150
+
151
+ </div>
152
+
153
+ </div>
154
+
155
+ </div>
156
+
157
+
158
+
159
+ <div class="lesson-wrapper">
160
+
161
+ <div class="container">
162
+
163
+ <div class="heading">
164
+
165
+ <h2>Learn Where to Get Started!</h2>
166
+
167
+ </div>
168
+
169
+ <div class="lessons">
170
+
171
+ <div class="lesson">
172
+
173
+ <div class="lesson-icon">
174
+
175
+ <img src="img/html.png">
176
+
177
+ <p>HTML&CSS</p>
178
+
179
+ </div>
180
+
181
+ <p class="text-contents">ウェブページの作成に使用される言語です。HTMLとCSSを組み合わせることで、静的なページを作り上げることができます。</p>
182
+
183
+ </div>
184
+
185
+ <div class="lesson">
186
+
187
+ <div class="lesson-icon">
188
+
189
+ <img src="img/jQuery.png">
190
+
191
+ <p>jQuery</p>
192
+
193
+ </div>
194
+
195
+ <p class="text-contents">素敵な動きを手軽に実装できるJavaScriptライブラリです。 アニメーション効果をつけたり、Ajax(エイジャックス)を使って外部ファイルを読み込んだりと色々なことができます。</p>
196
+
197
+ </div>
198
+
199
+ <div class="lesson">
200
+
201
+ <div class="lesson-icon">
202
+
203
+ <img src="img/ruby.png">
204
+
205
+ <p>Ruby</p>
206
+
207
+ </div>
208
+
209
+ <p class="text-contents">オープンソースの動的なプログラミング言語で、 シンプルさと高い生産性を備えています。大きなWebアプリケーションから小さな日用ツールまで、さまざまなソフトウェアを作ることができます。</p>
210
+
211
+ </div>
212
+
213
+ <div class="lesson">
214
+
215
+ <div class="lesson-icon">
216
+
217
+ <img src="img/php.png">
218
+
219
+ <p>PHP</p>
220
+
221
+ </div>
222
+
223
+ <p class="text-contents">HTMLだけではページの内容を変えることはできません。PHPはHTMLにプログラムを埋め込み、それを可能にします。</p>
224
+
225
+ </div>
226
+
227
+ </div>
228
+
229
+ </div>
230
+
231
+ </div>
232
+
233
+
234
+
235
+ <div class="message-wrapper">
236
+
237
+ <div class="container">
238
+
239
+ <div class="heading">
240
+
241
+ <h2>さぁ、あなたもProgateでプログラミングを学んでみませんか?</h2>
242
+
243
+ <h3>Let's learn to code, learn to be creative!</h3>
244
+
245
+ </div>
246
+
247
+ <span class="btn message">さっそく開発する</span>
248
+
249
+ </div>
250
+
251
+ </div>
252
+
253
+
254
+
255
+ <footer>
256
+
257
+ <div class="container">
258
+
259
+ <img src="img/footer_logo.png">
260
+
261
+ <p>Learn to Code, Learn to be Creative.</p>
262
+
263
+ </div>
264
+
265
+ </footer>
266
+
267
+
268
+
269
+ </body>
270
+
271
+
272
+
273
+ </html>
274
+
275
+
276
+
277
+ 【stylesheet.css】
278
+
279
+ body {
280
+
281
+ margin: 0;
282
+
283
+ font-family: "Hiragino Kaku Gothic ProN";
284
+
285
+ }
286
+
287
+
288
+
289
+ a {
290
+
291
+ text-decoration: none;
292
+
293
+ }
294
+
295
+
296
+
297
+ .container {
298
+
299
+ width: 100%;
300
+
301
+ margin: 0 auto;
302
+
303
+ }
304
+
305
+
306
+
307
+ header {
308
+
309
+ height: 65px;
310
+
311
+ width: 100%;
312
+
313
+ background-color: rgba(34,49,52,0.9);
314
+
315
+ position: fixed;
316
+
317
+ top: 0;
318
+
319
+ z-index: 10;
320
+
321
+ }
322
+
323
+
324
+
325
+ .logo {
326
+
327
+ width: 124px;
328
+
329
+ margin-top: 20px;
330
+
331
+ margin-left: 15px;
332
+
333
+ }
334
+
335
+
336
+
337
+ .header-left {
338
+
339
+ float: left;
340
+
341
+ }
342
+
343
+
344
+
345
+ .header-right {
346
+
347
+ float: right;
348
+
349
+ margin-left: 10px;
350
+
351
+ }
352
+
353
+
354
+
355
+ .header-right a {
356
+
357
+ line-height: 65px;
358
+
359
+ padding: 0 25px;
360
+
361
+ color: white;
362
+
363
+ display: block;
364
+
365
+ float: left;
366
+
367
+ transition: all 0.5s;
368
+
369
+ }
370
+
371
+
372
+
373
+ .header-right:hover {
374
+
375
+ background-color: rgba(255, 255, 255, 0.5);
376
+
377
+ }
378
+
379
+
380
+
381
+ .menu-icon {
382
+
383
+ color: white;
384
+
385
+ float: right;
386
+
387
+ font-size: 25px;
388
+
389
+ padding: 21px 0;
390
+
391
+ display: none;
392
+
393
+ }
394
+
395
+
396
+
397
+ .top-wrapper {
398
+
399
+ padding: 180px 0 100px 0;
400
+
401
+ background-image: url(img/top.png);
402
+
403
+ color: white;
404
+
405
+ background-size: cover;
406
+
407
+ text-align: center;
408
+
409
+ }
410
+
411
+
412
+
413
+ .top-wrapper h1 {
414
+
415
+ opacity: 0.7;
416
+
417
+ font-size: 45px;
418
+
419
+ letter-spacing: 5px;
420
+
421
+ }
422
+
423
+
424
+
425
+ .top-wrapper p {
426
+
427
+ opacity: 0.7;
428
+
429
+ font-size: 16px;
430
+
431
+ margin-bottom: 40px;
432
+
433
+ }
434
+
435
+
436
+
437
+ .btn {
438
+
439
+ padding: 8px 24px;
440
+
441
+ color: white;
442
+
443
+ display: inline-block;
444
+
445
+ opacity: 0.8;
446
+
447
+ border-radius: 4px;
448
+
449
+ text-align: center;
450
+
451
+ }
452
+
453
+
454
+
455
+ .signup {
456
+
457
+ background-color: #239b76;
458
+
459
+ }
460
+
461
+
462
+
463
+ .btn-wrapper p {
464
+
465
+ margin-bottom: 20px;
466
+
467
+ }
468
+
469
+
470
+
471
+ .facebook {
472
+
473
+ background-color: #3b5998;
474
+
475
+ margin-right: 10px;
476
+
477
+ }
478
+
479
+
480
+
481
+ .twitter {
482
+
483
+ background-color: #55acee;
484
+
485
+ }
486
+
487
+
488
+
489
+ .lesson-wrapper {
490
+
491
+ height: 580px;
492
+
493
+ padding-bottom: 80px;
494
+
495
+ padding-left: 5%;
496
+
497
+ padding-right: 5%;
498
+
499
+ background-color: #f7f7f7;
500
+
501
+ text-align: center;
502
+
503
+ }
504
+
505
+
506
+
507
+ .heading {
508
+
509
+ padding-top: 80px;
510
+
511
+ padding-bottom: 50px;
512
+
513
+ color: #5f5d60;
514
+
515
+ }
516
+
517
+
518
+
519
+ .heading h2 {
520
+
521
+ font-weight: normal;
522
+
523
+ }
524
+
525
+
526
+
527
+ .lesson {
528
+
529
+ float: left;
530
+
531
+ width: 25%;
532
+
533
+ }
534
+
535
+
536
+
537
+ .lesson-icon {
538
+
539
+ position: relative;
540
+
541
+ }
542
+
543
+
544
+
545
+ .lesson-icon p {
546
+
547
+ position: absolute;
548
+
549
+ top: 37%;
550
+
551
+ width: 100%;
552
+
553
+ color: white;
554
+
555
+ }
556
+
557
+
558
+
559
+ .text-contents {
560
+
561
+ width: 80%;
562
+
563
+ display: inline-block;
564
+
565
+ margin-top: 15px;
566
+
567
+ font-size: 13px;
568
+
569
+ color: #b3aeb5;
570
+
571
+ }
572
+
573
+
574
+
575
+ .message-wrapper {
576
+
577
+ border-bottom: 1px solid #eee;
578
+
579
+ padding-bottom: 80px;
580
+
581
+ text-align: center;
582
+
583
+ }
584
+
585
+
586
+
587
+ .heading {
588
+
589
+ padding-top: 80px;
590
+
591
+ padding-bottom: 50px;
592
+
593
+ color: #5f5d60;
594
+
595
+ }
596
+
597
+
598
+
599
+ .heading h2 {
600
+
601
+ font-weight: normal;
602
+
603
+ }
604
+
605
+
606
+
607
+ .heading h3 {
608
+
609
+ font-weight: normal;
610
+
611
+ }
612
+
613
+
614
+
615
+ .message {
616
+
617
+ padding: 15px 40px;
618
+
619
+ background-color: #5dca88;
620
+
621
+ cursor: pointer;
622
+
623
+ box-shadow: 0px 7px #1a7940;
624
+
625
+ }
626
+
627
+
628
+
629
+ .message:hover {
630
+
631
+ filter: brightness(1.10);
632
+
633
+ }
634
+
635
+
636
+
637
+ .message:active {
638
+
639
+ box-shadow: none;
640
+
641
+ position: relative;
642
+
643
+ top: 7px;
644
+
645
+ }
646
+
647
+
648
+
649
+ footer {
650
+
651
+ padding-top: 30px;
652
+
653
+ padding-bottom: 20px;
654
+
655
+ margin-left: 15px;
656
+
657
+ }
658
+
659
+
660
+
661
+ footer img {
662
+
663
+ width: 125px;
664
+
665
+ }
666
+
667
+
668
+
669
+ footer p {
670
+
671
+ color: #b3aeb5;
672
+
673
+ font-size: 12px;
674
+
675
+ }
676
+
677
+
678
+
679
+ 【responsive.css】
680
+
681
+ /* tab */
682
+
683
+ @media (max-width: 1000px) {
684
+
685
+ .lesson-wrapper {
686
+
687
+ height: 990px;
688
+
689
+ }
690
+
691
+ .lesson {
692
+
693
+ width: 50%;
694
+
695
+ margin-bottom: 50px;
696
+
697
+ }
698
+
699
+ }
700
+
701
+
702
+
703
+ /* sp */
22
704
 
23
705
  @media (max-width: 670px) {
24
706
 
@@ -48,6 +730,8 @@
48
730
 
49
731
  }
50
732
 
733
+
734
+
51
735
  ```
52
736
 
53
737