Forcing footer to bottom of page, if document height is smaller than window height

China☆狼群 提交于 2019-12-06 09:22:00

simply change javascript to:

if ($(document.body).height() < $(window).height()) {
  $('#footer-wrapper').attr('style', 'position: fixed!important; bottom: 0px;');
}

Unfortunately body height can be set to 100%. Here is the solution dealing only with footer

$(window).on('load resize scroll', function() {
    var f = $('#footer-wrapper');
    f.css({position:'static'});
    if (f.offset().top + f.height() < $(window).height()) {
        f.css({position:'fixed', bottom:'0', width:'100%'});
    }
});
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!