ページ コンテンツの高さがビュー ポートの高さよりも小さい場合、ビュー ポートのページ フッターの下部に合わせたいと思います。ページの高さがビュー ポートの高さを超える場合、フッターはそのコンテンツの下に配置する必要があります。
ビューポートの高さを確認して変更しました。ただし、一部のシナリオでは機能しません。
HTML:
<div id="page" class="page">
<div id="header"></div>
<div id="contentWrapper"></div>
<div id="footer"></div>
</div>
Javascript:
var vpHeight = getViewPort().height;
var contentHeight = $("#contentWrapper").height();
if (contentHeight < vpHeight) {
$("#footer").css("position", "absolute");
$("#footer").css("bottom", "0");
$("#goToTop").hide();
}
else {
$("#footer").css("position", "static");
$("#footer").css("bottom", "auto");
$("#goToTop").show();
}
function getViewPort() {
var e = window, a = 'inner';
if (!('innerWidth' in window)) {
a = 'client';
e = document.documentElement || document.body;
}
return { width: e[a + 'Width'], height: e[a + 'Height'] }
};