Div height 100% and expands to fit content

后端 未结 15 959
攒了一身酷
攒了一身酷 2020-11-29 15:51

I have a div element on my page with its height set to 100%. The height of the body is also set to 100%. The inner div has a background and all that and is different from t

15条回答
  •  孤独总比滥情好
    2020-11-29 16:11

    Modern browsers support the "viewport height" unit. This will expand the div to the available viewport height. I find it more reliable than any other approach.

    #some_div {
        height: 100vh;
        background: black;
    }
    

提交回复
热议问题