Go Back   SitePoint Forums > Forum Index > Design Your Site > Web Page Design > CSS
Newsletter FAQ Members List Calendar Mark Forums Read

New to SitePoint Forums? Register here for free!

SitePoint Sponsor
 
Reply
 
Thread Tools Display Modes
Old Mar 18, 2004, 19:23   #1
cranial-bore
SitePoint Wizard
 
cranial-bore's Avatar
 
Join Date: Jan 2002
Location: Australia
Posts: 2,092
Automatic DIV height to fill 100% screen height

Hi all, I am trying my first 'real' CSS layout and as expected am missing some of the simplier things of tabular layout.

In this instance I want my main content div (which spans the width of the page) to be liquid height so that the whole page takes up 100% of the browser height. The other elements (navigation bar etc) are all fixed pixel heights.

With tables this was simple, you set the table height to 100%, specified fixed pixels heights of all table rows, except one, and it would automatically fill the height of the browser.
No such luck in CSS using DIVs. Without this functionality my pages jump from taking up the full browser height, to only half depending on how much content is on the page.

I can't set a fixed pixel height or a percentage height for my main DIV because it would not work with varying resolutions, and the other DIVs need to be pixel specific because they have bitmap elements.

CSS is great, but I wish it was finished

Any help would be much appreciated.
cranial-bore is offline   Reply With Quote
Old Mar 19, 2004, 01:44   #2
Paul O'B
CSS Advisor
 
Paul O'B's Avatar
 
Join Date: Jan 2003
Location: Hampshire UK
Posts: 26,593
Hi,

Quote:
In this instance I want my main content div (which spans the width of the page) to be liquid height so that the whole page takes up 100% of the browser height
Code:
html,body {height:100%}
#outer {
height:100%;
min-height:100%;/*for mozilla*/
}
html>body #outer {height:auto}/*for mozilla */
html
Code:
<div id="outer">
All your content comes here.................
</div>
This is about the only way to achieve 100% height that I know of. It will only work for the first element as shown above (and works in about 95% of browsers).

Have a look at my 3 column thread which is stickied at the top of the threads for a long explanation of this technique as used in the demo.

Paul
Paul O'B is offline   Reply With Quote
Old Mar 19, 2004, 20:21   #3
cranial-bore
SitePoint Wizard
 
cranial-bore's Avatar
 
Join Date: Jan 2002
Location: Australia
Posts: 2,092
excellent thanks, I'll have a look at the thread.
cranial-bore is offline   Reply With Quote
Old Apr 27, 2005, 15:02   #4
Tellie2000
SitePoint Member
 
Join Date: Apr 2005
Posts: 5
This only worked for me in IE. Firefox, Netscape and Opera still display as before (i.e. the content only fill the needed area).

Any thoughts?
Tellie2000 is offline   Reply With Quote
Old Apr 27, 2005, 16:30   #5
yngwin
SitePoint Addict
 
Join Date: Sep 2003
Location: Europe
Posts: 222
http://www.sitepoint.com/forums/showthread.php?t=143801
yngwin is offline   Reply With Quote
Old Apr 28, 2005, 03:42   #6
Paul O'B
CSS Advisor
 
Paul O'B's Avatar
 
Join Date: Jan 2003
Location: Hampshire UK
Posts: 26,593
Quote:
This only worked for me in IE. Firefox, Netscape and Opera still display as before (i.e. the content only fill the needed area).

Any thoughts?
First thought are you didn't read my post correctly lol

Second thoughts are how did you find a year old thread to look at!

Third thoughts are as yngwin mentione above. Have a look at the FAQ and also the 3 col demo that uses the techniques mentioned. There is a long explanation of 100% height in the faq so take a look at that also.

Fourth thoughts are that you are nesting more than one element and trying to apply 100% height to them all which won't work for the reasons mentioned in the faq

If you want some specific help with your code then you'll have to post some code to look at so we can see what you are doing exactly
Paul O'B is offline   Reply With Quote
Old Apr 28, 2005, 12:59   #7
Tellie2000
SitePoint Member
 
Join Date: Apr 2005
Posts: 5
That thread is super helpful. Thanks!
Tellie2000 is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread | Next Thread »

Thread Tools
Display Modes

 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Sponsored Links
 
Forum Jump


All times are GMT -7. The time now is 18:43.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Copyright 1998-2009, SitePoint Pty Ltd. All Rights Reserved