Make Div Height 100% of Screen

后端 未结 3 843
抹茶落季
抹茶落季 2020-12-12 03:14

I have been reading all the 100% div height discussions and I can\'t find a simple solution. How can I make my div take up all of the vertical height of the screen?

相关标签:
3条回答
  • 2020-12-12 03:21

    You have to make the <body> tag of the height 100% as well, otherwise it is vertically truncated to fit the content.

    Also make sure to put the margin of <body> to 0px, because otherwise it will become 100%_of_visible_area + margin, resulting in a vertical scroll bar.

    0 讨论(0)
  • 2020-12-12 03:35

    Try to set height:100% for your <body> and <html>, too.
    If there is nothing except this div on your page, 100% height will be 0px without these settings.

    0 讨论(0)
  • 2020-12-12 03:36
    html, body {padding: 0px; margin: 0px; height: 100%;}
    

    http://jsfiddle.net/kEv8F/ - my version.

    http://jsfiddle.net/kEv8F/ - your version.

    Is that what you meant?

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