Results 1 to 2 of 2

Thread: Make a div fit the height of the page

  1. #1
    bumbala Guest

    Question Make a div fit the height of the page

    Hi experts,

    I am developing a website with a header (with variable height) and a content below. My problem is that I can't make the content div cover the whole page height.
    My css is like this:

    Code:
    html, body {
    margin: 0px;
    padding: 0px;
    width: 100%;
    height: 100%;
    }
    
    #header {
    width: 100%;
    }
    
    #content {
    height: 100%;
    width: 100%;
    }
    And my html code is like this:
    Code:
    <html>
    <body>
    <div id="header">blah blah blah</div>
    <div id="content"></div>
    </body>
    </html>
    The content div does not have anything in it. It is empty.

    In this case, the height of the content exceeds the page height and scrollbars appear. How can I exactly fit the content div to page height?

    Thank you.

  2. #2
    Join Date
    Feb 2006
    Location
    Salisbury UK
    Posts
    4,332
    If you put the #header inside the #content div, the #content div will then be 100% of the height and the #header can still be a variable height inside it.
    Code:
    <body> 
    <div id="content">
    <div id="header">blah blah blah</div>
    </div>
    </body>
    This shows something similar although it has a header tag instead of a header div:-
    http://www.wickham43.net/fullheightdiv.php
    Code downloaded to my PC will be deleted in due course.
    WIN7; IE9, Firefox, Opera, Chrome and Safari for Windows; screen resolution usually 1366*768.
    Also IE6 on W98 with 800*600 and IE8 on Vista 1440*900.

Similar Threads

  1. Help wanted embedding a MySpace page in a frame (or div)
    By random123 in forum Web Design, HTML Reference and CSS
    Replies: 0
    Last Post: 29 Mar 2009, 02:19 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •