Set div height equal to screen size

后端 未结 6 1618
情深已故
情深已故 2020-11-30 02:10

I have a div element in twitter-bootstrap which will have content that will overflow vertically outside the screen.

I would like the div to take the height of the si

6条回答
  •  心在旅途
    2020-11-30 02:56

    Using CSS {height: 100%;} matches the height of the parent. This could be anything, meaning smaller or bigger than the screen. Using {height: 100vh;} matches the height of the viewport.

    .container {
        height: 100vh;
        overflow: auto;
    }
    

    According to Mozilla's official documents, 1vh is:

    Equal to 1% of the height of the viewport's initial containing block.

提交回复
热议问题