How to stick a footer to bottom in css?

后端 未结 12 486
别跟我提以往
别跟我提以往 2020-12-01 05:09

I am having the classic problem for the positioning of a Footer on the bottom of the browser. I\'ve tried methods including http://ryanfait.com/resources/footer-stick-to-bot

相关标签:
12条回答
  • 2020-12-01 05:45

    Assuming you know the size of your footer, you can do this:

        footer {
            position: sticky;
            height: 100px;
            top: calc( 100vh - 100px );
        }
    
    0 讨论(0)
  • 2020-12-01 05:45

    I agree with Luke Vo's solution. I thought it would better to omit justify-content: space-between; from layout-wrapper and add margin-top: auto; to footer.

    You wouldn't want your body to be hanging in the middle and only have footer pushed to the bottom.

    This approach addresses any content extending beyond the viewport.

    0 讨论(0)
  • 2020-12-01 05:46
    #footer{
    position: fixed; 
    bottom: 0;
    }
    

    http://codepen.io/smarty_tech/pen/grzMZr

    0 讨论(0)
  • 2020-12-01 05:47

    Try setting the styles of your footer to position:absolute; and bottom:0;.

    0 讨论(0)
  • 2020-12-01 05:48

    I had a similar issue with this sticky footer tutorial. If memory serves, you need to put your form tags within your <div class=Main /> section since the form tag itself causes issues with the lineup.

    0 讨论(0)
  • 2020-12-01 05:51

    I think a lot of folks are looking for a footer on the bottom that scrolls instead of being fixed, called a sticky footer. Fixed footers will cover body content when the height is too short. You have to set the html, body, and page container to a height of 100%, set your footer to absolute position bottom. Your page content container needs a relative position for this to work. Your footer has a negative margin equal to height of footer minus bottom margin of page content. See the example page I posted.

    Example with notes: http://markbokil.com/code/bottomfooter/

    0 讨论(0)
提交回复
热议问题