Forum Moderators: not2easy

Message Too Old, No Replies

Div layout with 100% height and CSS

Div layout with 100% height and CSS

         

sortamusic

1:45 am on Feb 20, 2008 (gmt 0)

10+ Year Member



I'm trying to create a page with a header, footer, left nav, and center content. I need the footer to be at the bottom of the browser window and the center content to fill the space between the header and the footer. Ultimately, I'll be adding an IFrame to the center content DIV that fills the center content area. The html that I have so far is below and I think I'm pretty close, but it's not quite there. Please help:

<html>
<head>
<STYLE TYPE="text/css">
<!--
html,body, form
{
height: 100%;
margin: 0;
padding: 0;
background-color: white;
}

#Header
{
height: 60px;
background-color: white;
}

#Middle
{
_height: 100%;/* underscore-hack for IE */
min-height: 100%;
margin-top: -80px; /* #Header height + the margin-bottom */
margin-bottom: -20px;
background-color: Aqua;
}

#MarginTop
{
height: 100px;
}

#MarginBottom
{
height: 20px;
}

#Footer
{
clear: both;
height: 20px;
font-size: 8pt;
color: Gray;
text-align:center;
}

#NavTree
{
float: left;
width: 300px;
height: 100%;
padding-left: 10px;
border: solid 1px red;
}

#ContentArea
{
text-align: left;
_height: 100%; /* underscore-hack for IE */
height: 100%;
min-height: 100%;
background-color: Lime;
}
-->
</STYLE>
</head>
<body>

<div id="Header">
My header text
</div>
<div id="Middle">
<div id="MarginTop"></div>
<div id="NavTree">
Left Nav
</div>
<div id="ContentArea">
I want to put an IFrame here that fills this area.
</div>
</div>
<div id="MarginBottom"></div>
<div id="Footer">
My footer text
</div>

</body>
</html>

ratman7

1:59 am on Feb 20, 2008 (gmt 0)

10+ Year Member



What's not working?

sortamusic

2:06 am on Feb 20, 2008 (gmt 0)

10+ Year Member



2 Things:

1. In IE and Firefox, the height of the layout is taller than the viewing area in the browser (creating a vertical scrollbar).

2. In Firefox, the ContentArea div is expanding the entire width of the viewing area. I want it to start to the right of the "NavTree" DIV.

ratman7

5:10 am on Feb 20, 2008 (gmt 0)

10+ Year Member



If you don't want a vertical scroll, make the height of your containing element less than 100%.

sortamusic

1:59 pm on Feb 20, 2008 (gmt 0)

10+ Year Member



That is not an accurate statement. If I were to set the percentage to 90% (for example) then I would either still have a scrollbar or the content area would not fill the entire space (depending on the window height).