How can an html element fill out 100% of the remaining screen height, using css only?

后端 未结 17 1821
名媛妹妹
名媛妹妹 2020-12-22 16:13

I have a header element and a content element:

#header
#content

I want the header to be of fixed height and the content to fill up all the

17条回答
  •  北海茫月
    2020-12-22 16:51

    For me, the next worked well:

    I wrapped the header and the content on a div

    I used this reference to fill the height with flexbox. The CSS goes like this:

    .main-wrapper {
        display: flex;
        flex-direction: column;
        min-height: 100vh;
    }
    .header {
        flex: 1;
    }
    .content {
        flex: 1;
    }
    

    For more info about the flexbox technique, visit the reference

提交回复
热议问题