Resize div height to height of browser window (-) 50px

Posted on 2005-05-09
Last Modified: 2010-04-06
I need to resize the main div of my site so that it does not stop at the bottom of the content, but goes all the way down to the bottom of the window. I am currently using safari (i would like a cross-browser compatible solution).
Here is my css:

#main {
 margin:0 auto;
 width:390px; height:100%;
 top:50px; bottom:0px;

I have tried several different ways of resizing through javascript to no avail( ie. document.getElementById('main').style.height = h; //h=document.height-50

Any ideas?

Question by:dh2oing
    LVL 13

    Accepted Solution

    in a frame:
    function resize(){  
    var frame = document.getElementById("frame1");  
    var htmlheight = document.body.parentNode.scrollHeight;  
    var windowheight = window.innerHeight;  
    if ( htmlheight < windowheight ) { = windowheight + "px"; = windowheight + "px"; }  
    else { = htmlheight + "px"; = htmlheight + "px"; }  

    Does that help?

    Author Comment

    It is only a div, but yes you helped: I forgot the ="px"

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    RSS Feeds--IE 13 139
    Display recordset field HTML encoded 21 38
    Tech Writing Terminology - Pane or Panel? 8 56
    Microsoft Edge 9 69
    Preface In the first article: A Better Website Login System ( I introduced the EE Collaborative Login System and its intended purpose. In this article I will discuss some of the design consideratio…
    Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL ( several years ago, it seemed like now was a good time to updat…
    Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
    HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

    732 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now