Forum Moderators: not2easy

Message Too Old, No Replies

Div reaching top to bottom with room for a header.

         

kmler

9:44 pm on Dec 23, 2008 (gmt 0)

10+ Year Member



Hello,

At first I needed a div to fill the whole page. I know that to get this to work I need to set html and body both to 100% high. Did that, and this code works:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title></title>
<style type="text/css">
html{width:100%;height:100%;margin:0;padding:0}
body{width:100%;height:100%;margin:0;padding:0}
#w{width:100%;height:100%;margin:0;padding:0;background:#abcdef}
</style>
</head>

<body>
<div id="w"></div>
</body>
</html>

But my needs are a little bit different.

I need to have a header (#h) at the top of my page that's 90px high, then with a div below that that fills in the rest of the screen, basically 100%-90px.

I've been playing around, and came across a fix for ie, but I was hoping I might be able to get something that works in more browsers, especially firefox. Any ideas?

This is what I have now:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title></title>
<style type="text/css">
html{width:100%;height:100%;margin:0;padding:90px 0 0}
body{width:100%;height:100%;margin:0;padding:0}
#h{height:90px;width:100%;margin:0;padding:0;position:absolute;top:0;left:0;background:#abcdef}
#w{margin:0;padding:0;background:#fedcba}
</style>
</head>

<body>
<div id="h"></div>
<div id="w"></div>
</body>
</html>

swa66

10:14 pm on Dec 23, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I think it's rather important to consider two cases in all "100% height" instances:
- What do you want to happen when the content isn't filling the screen
(mostly that is answered to some extend: stretch something, but often
it might mean stretch a parent, and place a footer etc.)
- What do you want to happen when the content is too large for the screen ?
(mostly this isn't answered)

kmler

12:28 am on Dec 24, 2008 (gmt 0)

10+ Year Member



Thank you for the reply.

The header would be a fixed height showing a header, designed for a liquid layout. It would only greacefully hide content in a very tight window size. So I'm not worried about that.

The rest of the body, the w for wrap, is set up to allow for panning, zooming in and zooming out, with its own set of controls, so that content will always be filling the screen, and/or too large for the screen. Both are fun.

But I know how to get the w div to be full screen, how can I adjust the css to allow for a static header.

Thanks