回答編集履歴
2
追記
answer
CHANGED
@@ -144,4 +144,84 @@
|
|
144
144
|
<footer> </footer>
|
145
145
|
</body>
|
146
146
|
</html>
|
147
|
+
```
|
148
|
+
|
149
|
+
---
|
150
|
+
|
151
|
+
**追記**
|
152
|
+
コメント欄にて「macOSでは、上記のコードを実行すると、`footer`要素の横幅が`100%`にならず、正常に動作しない」とのコメントを頂きました。
|
153
|
+
現在、この問題を検証出来ない環境にいるため、原因はわかりませんが、`width`プロパティに`100%`を指定することで、この問題を解消することが可能なようです。
|
154
|
+
```HTML
|
155
|
+
<!DOCTYPE html>
|
156
|
+
<html lang="ja">
|
157
|
+
<head>
|
158
|
+
<meta charset="UTF-8">
|
159
|
+
<title>Document</title>
|
160
|
+
<style>
|
161
|
+
html, body {
|
162
|
+
display: flex;
|
163
|
+
flex-direction: column;
|
164
|
+
height: 100%;
|
165
|
+
width: 100%;
|
166
|
+
margin: 0;
|
167
|
+
padding: 0;
|
168
|
+
}
|
169
|
+
|
170
|
+
header {
|
171
|
+
position: fixed;
|
172
|
+
background-color: #333;
|
173
|
+
height: 70px;
|
174
|
+
width: 100%;
|
175
|
+
min-width: 960px;
|
176
|
+
}
|
177
|
+
|
178
|
+
.contents {
|
179
|
+
width: 960px;
|
180
|
+
background-color: #eee;
|
181
|
+
margin: 70px auto 0;
|
182
|
+
}
|
183
|
+
|
184
|
+
.left-content {
|
185
|
+
background-color: red;
|
186
|
+
width: 700px;
|
187
|
+
height: 400px;
|
188
|
+
float: left;
|
189
|
+
}
|
190
|
+
|
191
|
+
.right-content {
|
192
|
+
background-color: yellow;
|
193
|
+
width: 260px;
|
194
|
+
height: 300px;
|
195
|
+
float: right;
|
196
|
+
}
|
197
|
+
|
198
|
+
.bottom-content {
|
199
|
+
background-color: green;
|
200
|
+
height: 250px;
|
201
|
+
margin-top: 400px;
|
202
|
+
}
|
203
|
+
|
204
|
+
.clearfix::after {
|
205
|
+
content: "";
|
206
|
+
display: block;
|
207
|
+
clear: both;
|
208
|
+
}
|
209
|
+
|
210
|
+
footer {
|
211
|
+
width: 100%; /* macOSの場合 */
|
212
|
+
height: 60px;
|
213
|
+
background-color: #333;
|
214
|
+
}
|
215
|
+
</style>
|
216
|
+
</head>
|
217
|
+
<body>
|
218
|
+
<header> </header>
|
219
|
+
<div class="contents clearfix">
|
220
|
+
<div class="left-content"></div>
|
221
|
+
<div class="right-content"></div>
|
222
|
+
<div class="bottom-content"></div>
|
223
|
+
</div>
|
224
|
+
<footer> </footer>
|
225
|
+
</body>
|
226
|
+
</html>
|
147
227
|
```
|
1
修正
answer
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
`footer`要素がコンテンツの中に入ってしまっている原因は、既に他の回答者さんが書かれているように、`footer`要素が`div.contents`内に入っているからです。
|
2
|
-
|
2
|
+
質問者さんは、「ページ全体に対するフッター」を設定したいのだと思います。
|
3
3
|
しかし、質問文のコードでは、「`div.contents`に対するフッター」を設定してしまっています。
|
4
4
|
そこで、この問題を解決するためには、まずはHTML構造を修正する必要があると思います。
|
5
5
|
今回の場合、HTML構造は以下のようになります。
|