When using “height: 100vh” for the container, vertical scrollbar appears

后端 未结 7 1019
花落未央
花落未央 2020-12-09 02:28

I want the content to take the full height of the browser window, but not beyond.

When using 100vh as the container height, I can see the vertical scrollbar appearin

相关标签:
7条回答
  • 2020-12-09 02:46

    By default body and html are assigned to margin or padding to some pixels. Try using following code.

    1vh = 1% of veiwport height 100vh = 100% of height.

    So never calculate height - 3px. like this

    body,html {
        margin: 0;
        padding: 0;
    }
    * {
        box-sizing: border-box;
    }
    
    0 讨论(0)
提交回复
热议问题