Why does 100% not mean 100% height?

前端 未结 6 1920
南方客
南方客 2020-12-03 06:05

I am trying to get some divss to expand to fill the screen, but I am struggling. I have broken down the issue on this jsfiddle.

What I really want to kn

6条回答
  •  南笙
    南笙 (楼主)
    2020-12-03 06:15

    You need to also set the height of the html so that 100% refers to the viewport height instead of the document height (demo):

    html,body {
        height: 100%;
        background: red;
        padding: 0;
    }
    div {
        height: 100%;
        background: grey;
    }
    

提交回复
热议问题