How to push a footer to the bottom of page when content is short or missing?

前端 未结 13 1326
囚心锁ツ
囚心锁ツ 2020-12-04 16:55

I have a page with an outer div that wraps a header, content and footer div. I want the footer div to hug the bottom of the browser, even when the content div is not tall e

13条回答
  •  一个人的身影
    2020-12-04 17:25

    You can do exactly what you want using Flexbox, as an example will be:

    html, body {
        height: 100%;
        width: 100%;
    }
    
    .wrapper {
        display: flex;
        flex-direction: column;
        min-height: 100%;
    }
    
    .content {
        flex-grow: 1;
    }
    

    as a note the footer must be outside the content element

    html structure will be something like follow:

    
        
            

提交回复
热议问题