0

I want to fill the screen (width and height) on any size with a <header>:

<header></header>
    <div id="content"></div>
<footer></footer>

The <header> should always fill the whole screen on any height of monitor also in iPad, such that the content of <div id="content"> will only be seen after scrolling, not before that.

Joseph Silber
  • 214,931
  • 59
  • 362
  • 292
Jitendra Vyas
  • 148,487
  • 229
  • 573
  • 852
  • possible duplicate of [How to create div to fill all space between header and footer div](http://stackoverflow.com/questions/206652/how-to-create-div-to-fill-all-space-between-header-and-footer-div) – Loktar Aug 22 '11 at 14:25

3 Answers3

6

Simply give your html, body & header a height of 100%:

html, body, header {
    height: 100%
}

http://jsfiddle.net/tujsj/

Joseph Silber
  • 214,931
  • 59
  • 362
  • 292
4

You can use the new and so-useful-I-can't-imagine-what-took-W3C-so-long vh CSS unit:

<header style="height: 100vh"></header>
    <div id="content">must scroll to see this</div>
<footer></footer>
Dan Dascalescu
  • 143,271
  • 52
  • 317
  • 404
2

Have you tried using javascript, specifically jquery to handle this?

If you include jquery in your head tag, then you can use something like this:

$(document).ready(function(){
    $("#header").height($(window).height());
});
box86rowh
  • 3,415
  • 2
  • 26
  • 37
  • with the css approach, be sure to test on multiple browsers and versions as I have had mixed results with height 100%. – box86rowh Aug 22 '11 at 15:12