CSS Sticky Footers with Unknown Height

前端 未结 7 1579
自闭症患者
自闭症患者 2020-11-30 00:41

Is there any way to stick a footer to the bottom of the browser screen or right after the content (depending on which is longer) using CSS without knowing the size

7条回答
  •  北海茫月
    2020-11-30 01:01

    since no one knows the answer for sticky footer w/o knowing the height of it, using css (crosbrowser solution), i was forced to calculate it

    jquery:

    if( $(document).height() < $(window).height() )
    {
        $('#content').height
        (
            $(window).height - $('#footer').height()
        );
    }
    

    html structure:

提交回复
热议问题