動的な高さ (成長するコンテンツ) を持つ div の下部にあるスティッキー フッターを取得しようとしています。div はページの中央に配置する必要があります (左右から同じ距離)。
私は次のHTMLを持っています(無関係なものを取り除いています):
<html>
<body>
<div class="bodybackground">
<div class="container"><!-- floats in the middle -->
<div class="mainContainer"><!-- different color etc -->
<!-- content with dynamic height -->
</div>
<footer class="pagefooter"></footer>
</div>
</div>
</body>
</html>
および次の CSS (無関係なものも削除されています):
html {
height: 100%;
margin: 0px;
padding: 0px;
}
body {
margin: 0px;
height: 100%;
}
.bodybackground {
height: 100%;
min-height: 100%;
}
.container {
min-height: 100%;
display: inline-block; /* needed make it float in the middle of body */
top: 0px;
position: relative;
padding: 0px;
padding-bottom: 158px; /* height of footer */
}
.mainContainer {
position: absolute;
height: 100%;
overflow: auto;
}
.pagefooter {
position: absolute;
bottom: 0px;
margin: 0px;
padding: 0px;
height: 158px;
}
それでも、mainContainer のコンテンツは、フッターが一番下にあるのではなく、フッターの後ろに浮かんで続きます。コンテナの表示プロパティを強制的に変更する例を除いて、見つけることができるすべてのことを試しました。これは、コンテナを真ん中に浮かせておく必要があるためです。
私がばかである場所の手がかりはありますか?ありがとう!!
.push をもう少しいじる必要がありましたが、問題は解決しました。素早い回答ありがとうございます。