Align all content with the bottom of the page?

后端 未结 4 1372
抹茶落季
抹茶落季 2021-01-14 08:58

I\'m trying to align a html-page with the bottom of the browser-window. This is my apporach:


  
4条回答
  •  轮回少年
    2021-01-14 09:36

    I would just give your outer-wrapper a height of 100% (along with html, body):

    html, body {
        height: 100%;
        padding: 0;
        margin: 0;
    }
    
    .outer-wrapper {
        height: 100%;
        width: 100%;
        position: absolute;
        bottom: 0;
        overflow-y: auto;
        background-position:bottom; //Edit
    }
    

    Then the outer-wrapper will always keep the body's height. There’s no need for the 950px height min because in the case that the viewport is too small you wanted for this to scroll and in the other case the viewport is bigger than 950px - well, it's bigger than 950px - that's a good thing.

提交回复
热议问题