Forum Moderators: not2easy

Message Too Old, No Replies

FireFox Height 100% Not Resizing

FireFox Height 100% Overflows DIVs

         

waffler

2:34 am on Apr 18, 2006 (gmt 0)

10+ Year Member



FireFox seems to not resize divs correctly -- or at least not the way I wish it would -- when I use a height of 100%. I want the div to be as tall as the entire page.

I have the body, html, and container <div> all with a height of 100%.

Ex:
html, body
{
height: 100%;
}

#container
{
height: 100%;
}

When the text is rezised it overflows the bottom of the div.

Here is some sample code (stolen from someone else's post while I was looking for answers). Resize the font to be large anough to go off the bottom of the screen and you will see the problem.

-----
<?xml version="1.0" encoding="UTF-8"?>
<!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>One Hundred Percent height Divs</title>
<style type="text/css" media="screen">
body {
margin:0;
padding:0;
height:100%; /* this is the key! */
}
#left {
position:absolute;
left:0;
top:0;
padding:0;
width:200px;
height:100%; /* works only if parent container is assigned a height value */
color:#333;
background:#eaeaea;
border:1px solid #333;
}
.content {
margin-left:220px;
margin-right:220px;
margin-bottom:20px;
color:#333;
background:#ffc;
border:1px solid #333;
padding:0 10px;
}
#right {
position:absolute;
right:0;
top:0;
padding:0;
width:200px;
height:100%; /* works only if parent container is assigned a height value */
color:#333;
background:#eaeaea;
border:1px solid #333;
}

#left p {
padding:0 10px;
}
#right p {
padding:0 10px;
}
p.top {
margin-top:20px;
}
</style>
</head>

<body>
<div id="left">
<p class="top">This design uses a defined body height of 100% which allows setting the
contained left and right divs at 100% height.</p>

<p>This design uses a defined body height of 100% which allows setting the contained left and
right divs at 100% height.</p>

<p>This design uses a defined body height of 100% which allows setting the contained left and
right divs at 100% height.</p>
</div>

<div class="content">
<p>This design uses a defined body height which of 100% allows setting the contained left and
right divs at 100% height.</p>
</div>

<div class="content">
<p>This design uses a defined body height which of 100% allows setting the contained left and
right divs at 100% height.</p>
</div>

<div class="content">
<p>This design uses a defined body height which of 100% allows setting the contained left and
right divs at 100% height.</p>
</div>

<div id="right">
<p class="top">To solve an inheritance issue displayed in div #right as rendered in Opera, class p.top
using margin-top:20; is applied to the first paragraph of each outer divs.</p>

<p>This design uses a defined body height which of 100% allows setting the contained left and
right divs at 100% height.</p>

<p>This design uses a defined body height which of 100% allows setting the contained left and
right divs at 100% height.</p>
</div>
</body>
</html>

waffler

3:06 am on Apr 18, 2006 (gmt 0)

10+ Year Member



I found a solution by setting min-height to 100% and leaving height as it's default. The problem is, now it does not work in Internet Explorer. The box does not go down all the way.

Setek

3:16 am on Apr 18, 2006 (gmt 0)

10+ Year Member



IE doesn't accept min-height. However, it interprets height as min-height, in a way.

You could use conditional comments to explicitly set height for IE only, and use min-height for standards compliant browsers.

waffler

3:42 am on Apr 18, 2006 (gmt 0)

10+ Year Member



Perfect! Thanks!

For those who might not know, conditional comments are used like the following:

<!--[if IE]>
<script>
#container {
height: 100%;
}
</script>
<![endif]-->

Setek

3:49 am on Apr 18, 2006 (gmt 0)

10+ Year Member



That should be
<style type="text/css">selector { property: value; }</style>
:)

waffler

11:06 pm on Apr 18, 2006 (gmt 0)

10+ Year Member



Oops. Thanks. It was pretty late when I wrote that.