回答編集履歴

2

追記

2018/10/06 16:53

投稿

s8_chu
s8_chu

スコア14731

test CHANGED
@@ -291,3 +291,163 @@
291
291
  </html>
292
292
 
293
293
  ```
294
+
295
+
296
+
297
+ ---
298
+
299
+
300
+
301
+ **追記**
302
+
303
+ コメント欄にて「macOSでは、上記のコードを実行すると、`footer`要素の横幅が`100%`にならず、正常に動作しない」とのコメントを頂きました。
304
+
305
+ 現在、この問題を検証出来ない環境にいるため、原因はわかりませんが、`width`プロパティに`100%`を指定することで、この問題を解消することが可能なようです。
306
+
307
+ ```HTML
308
+
309
+ <!DOCTYPE html>
310
+
311
+ <html lang="ja">
312
+
313
+ <head>
314
+
315
+ <meta charset="UTF-8">
316
+
317
+ <title>Document</title>
318
+
319
+ <style>
320
+
321
+ html, body {
322
+
323
+ display: flex;
324
+
325
+ flex-direction: column;
326
+
327
+ height: 100%;
328
+
329
+ width: 100%;
330
+
331
+ margin: 0;
332
+
333
+ padding: 0;
334
+
335
+ }
336
+
337
+
338
+
339
+ header {
340
+
341
+ position: fixed;
342
+
343
+ background-color: #333;
344
+
345
+ height: 70px;
346
+
347
+ width: 100%;
348
+
349
+ min-width: 960px;
350
+
351
+ }
352
+
353
+
354
+
355
+ .contents {
356
+
357
+ width: 960px;
358
+
359
+ background-color: #eee;
360
+
361
+ margin: 70px auto 0;
362
+
363
+ }
364
+
365
+
366
+
367
+ .left-content {
368
+
369
+ background-color: red;
370
+
371
+ width: 700px;
372
+
373
+ height: 400px;
374
+
375
+ float: left;
376
+
377
+ }
378
+
379
+
380
+
381
+ .right-content {
382
+
383
+ background-color: yellow;
384
+
385
+ width: 260px;
386
+
387
+ height: 300px;
388
+
389
+ float: right;
390
+
391
+ }
392
+
393
+
394
+
395
+ .bottom-content {
396
+
397
+ background-color: green;
398
+
399
+ height: 250px;
400
+
401
+ margin-top: 400px;
402
+
403
+ }
404
+
405
+
406
+
407
+ .clearfix::after {
408
+
409
+ content: "";
410
+
411
+ display: block;
412
+
413
+ clear: both;
414
+
415
+ }
416
+
417
+
418
+
419
+ footer {
420
+
421
+ width: 100%; /* macOSの場合 */
422
+
423
+ height: 60px;
424
+
425
+ background-color: #333;
426
+
427
+ }
428
+
429
+ </style>
430
+
431
+ </head>
432
+
433
+ <body>
434
+
435
+ <header>&nbsp;</header>
436
+
437
+ <div class="contents clearfix">
438
+
439
+ <div class="left-content"></div>
440
+
441
+ <div class="right-content"></div>
442
+
443
+ <div class="bottom-content"></div>
444
+
445
+ </div>
446
+
447
+ <footer>&nbsp;</footer>
448
+
449
+ </body>
450
+
451
+ </html>
452
+
453
+ ```

1

修正

2018/10/06 16:52

投稿

s8_chu
s8_chu

スコア14731

test CHANGED
@@ -1,6 +1,6 @@
1
1
  `footer`要素がコンテンツの中に入ってしまっている原因は、既に他の回答者さんが書かれているように、`footer`要素が`div.contents`内に入っているからです。
2
2
 
3
- 今回、質問者さんは、「ページ全体に対するフッター」を設定したいのだと思います。
3
+ 質問者さんは、「ページ全体に対するフッター」を設定したいのだと思います。
4
4
 
5
5
  しかし、質問文のコードでは、「`div.contents`に対するフッター」を設定してしまっています。
6
6