How to properly set the 100% DIV height to match document/window height?

前端 未结 9 1825
难免孤独
难免孤独 2021-01-30 04:53

I have a wrapper positioned to center with an y-repeated background image:


    
...some content
&
相关标签:
9条回答
  • 2021-01-30 05:18
    html, body {
        height:100%;
    }
    #wrapper {
        min-height:100%;
    }
    
    0 讨论(0)
  • 2021-01-30 05:20

    Use #element{ height:100vh}

    This will set the height of the #element to 100% of viewport. Hope this helps.

    0 讨论(0)
  • 2021-01-30 05:25

    simplest way i found is viewport-height in css..

    div {height: 100vh;}
    

    this takes the viewport-height of the browser-window and updates it during resizes.

    see "can i use" for browser compatibility list

    0 讨论(0)
提交回复
热议问题