Keeping HTML footer at the bottom of the window if page is short

前端 未结 6 1021
日久生厌
日久生厌 2020-12-09 19:46

Some of my webpages are short. In those pages, the footer might end up in the middle of the window and below the footer is whitespace (in white). That looks ugly. I\'d like

6条回答
  •  有刺的猬
    2020-12-09 20:01

    Considering that all your footer is inside the

    html tag, this is an easy solution using jQuery.

    JS:

    $(document).ready(function(){
        $('body').css('padding-bottom', $('footer').height()+'px');
    });
    

    CSS:

    footer {
        position:absolute;
        bottom:0;
    }
    

提交回复
热议问题