CSS to make HTML page footer stay at bottom of the page with a minimum height, but not overlap the page

前端 未结 29 2517
悲哀的现实
悲哀的现实 2020-11-21 23:48

I have the following page (deadlink: http://www.workingstorage.com/Sample.htm ) that has a footer which I can\'t make sit at the bottom of the page.

I wa

29条回答
  •  臣服心动
    2020-11-22 00:25

    My jquery method, this one puts the footer at the bottom of the page if the page content is less than the window height, or just puts the footer after the content otherwise:

    Also, keeping the code in it's own enclosure before other code will reduce the time it takes to reposition the footer.

    (function() {
        $('.footer').css('position', $(document).height() > $(window).height() ? "inherit" : "fixed");
    })();
    

提交回复
热议问题