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

前端 未结 29 2445
悲哀的现实
悲哀的现实 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条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-22 00:22

    Do this

    You can also read about flex it is supported by all modern browsers

    Update: I read about flex and tried it. It worked for me. Hope it does the same for you. Here is how I implemented.Here main is not the ID it is the div

    body {
        margin: 0;
        display: flex;
        min-height: 100vh;
        flex-direction: column;
    }
    
    main {
        display: block;
        flex: 1 0 auto;
    }
    

    Here you can read more about flex https://css-tricks.com/snippets/css/a-guide-to-flexbox/

    Do keep in mind it is not supported by older versions of IE.

提交回复
热议问题