Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is html,body{height:100%} causing a scroll bar to appear?

Tags:

html

css

I'm trying to create a website that has a 'panel div on the left, and 'content' div on the right, both contained within <body>, and I want them to dynamically expand height to the size of the window. The problem is, when I use html,body{height:100%}, there is a scroll bar appearing. I'm hesitant to post full code of what I'm doing, but it is doing this still with a stripped down to:

    <!DOCTYPE HTML>
    <HTML>
      <HEAD>
        <STYLE>
          html, body {height:100%}
        </STYLE>
      <BODY>
      </BODY>
    </HTML>

so I don't think anything I'm doing could be messing with it...

I will try to provide more info upon request.

like image 808
Daevin Avatar asked Nov 30 '22 01:11

Daevin


2 Answers

HTML/BODY got standard padding/margin going on

try:

  <!DOCTYPE HTML>
<HTML>
  <HEAD>
    <STYLE>
      html, body {height:100%;
        margin:0;
        padding:0;}
    </STYLE>
  </HEAD>
  <BODY>
  </BODY>
</HTML>
like image 63
Dennis Anderson Avatar answered Dec 09 '22 21:12

Dennis Anderson


<body> has 8 pixels of margin around it by default, which falls outside the 100% height.

You need to remove that.

like image 43
SLaks Avatar answered Dec 09 '22 22:12

SLaks