私が作成したHTMLページ内に、フッターを追加したかったのです。私はブートストラップを利用していて、フッタ要素をコンテナ要素の中に(コンテナ要素の下の本体要素内に直接)置かずにフッター要素をページの下部に配置することができることが示されています(this example)。ブートストラップフッタ要素の位置の底面
私はこれを自分で試してみると、最初に要素が下に配置されているように見えます。しかし、私は他のページ(内容が長かったもの)に気づいたので、フッタはbody要素ではなくブラウザの一番下に現れ始めました。その効果は、フッターの上にあるコンテナ要素が、フッターが本体要素の底に向かうことなくフッターの後ろに表示されることです。
は私が作ったコードの次の例にスクロールするようにしてください:私は私のフッター要素が(ちょうどBootstrap example内の1つのように動作させるために何ができるか
.body {
overflow: scroll;
background-color: tomato;
/*The height is set so that an overflow: scroll; can happen, to reproduce
my sitation. When the content of the body tag is too long, the browser will
show a scroll bar and when scrolling down, the footer does not appear on the
bottom anymore but somewhere in the middle or maybe even top side, depending on
how long the body would become. */
height: 300px;
position: relative;
}
.container {
background-color: yellow;
/*This would be a dynamic number, when removing this property.
If you do not really understand the idea I am talking about, try to change
this value and see for yourself what happens (with the footer element).
The height is set only for the sake of showing the issue. */
height: 500px;
}
footer {
background: #e0f2f7;
position: absolute;
bottom: 0;
width: 100%;
}
<div class="body">
<h2>
Foo
</h2>
<div class="container">
asdasds
</div>
<footer>sadasdsa</footer>
</div>
そのため、常に下部に固執します)、フッタ要素を特定のコンテナ要素に配置する必要はありませんか?
は、オーバーフローのアイデアは動作しません。基本的には、ブラウザに(または)スクロールバーが表示されるようなコンテンツを含むbody要素があり、同様の状況が発生します。 – Barrosy