Why doesn't min-height not work on my page?

前端 未结 6 1885
忘掉有多难
忘掉有多难 2021-01-01 09:03

I have a gradient applied to the background of the body element. Then I have a container (right after body) that has a background .png image applied to it. The gradient alwa

6条回答
  •  别那么骄傲
    2021-01-01 09:30

    Using vh instead of % worked for me without having to use any extra tricks.

    This is what I have:

    html, body, .wrapper {
        min-height: 100vh;
    }
    

    Where .wrapper is the class you apply to your container/wrapper or main body of content that you wish to stretch the full length of the screen height.

    This will work as you would expect it to when the content within the wrapper is less or more than the screen height allows.

    This should work in most browsers.

提交回复
热议问题