Forum Moderators: not2easy

Message Too Old, No Replies

<div> size different between IE and NN

I hate NN, no IE, no, uh, D'OH!

         

Lance

9:55 pm on Aug 4, 2004 (gmt 0)

10+ Year Member



I have the following code, which validates XHTML and CSS. In IE 6 (compliant mode) it works exactly as I expected it to, and as I wish it to. #Outer is centered on the page with a fixed margin around the outside. #Inner is centered within #Outer, and takes up as much height as needed, forcing #Outer to scroll when necessary.

In NN 7.1 however, #Outer extends beyond the right and lower edges of the window, and #Inner extends beyond the right edge.

Is there any way to get this to work in NN as it does in IE?

Thanks in advance.


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html>
<head>
<title>Test</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
HTML,
BODY
{
POSITION: absolute;
TOP: 0px;
LEFT: 0px;
HEIGHT: 100%;
WIDTH: 100%;
BORDER: 0px none;
MARGIN: 0px;
PADDING: 42px;
OVERFLOW: hidden;
}

#Outer
{
BORDER: red 1px solid;
HEIGHT: 100%;
OVERFLOW: auto;
}
#Inner
{
BORDER: blue 1px solid;
}
</style>
</head>

<body>
<div id="Outer">
<div id="Inner">
<p>MainMainMainMainMain</p>
<p>MainMainMainMainMain</p>
<p>MainMainMainMainMain</p>
<p>MainMainMainMainMain</p>
<p>MainMainMainMainMain</p>
<p>MainMainMainMainMain</p>
</div>
</div>
</body>
</html>

Reflection

10:15 pm on Aug 4, 2004 (gmt 0)

10+ Year Member



Try this...

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html>
<head>
<title>Test</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
BODY{
BORDER: 0;
MARGIN: 0;
PADDING: 42px;
OVERFLOW: hidden;
}

#Outer{
BORDER: 1px solid red;
HEIGHT: 100%;
OVERFLOW: auto;
}
#Inner{BORDER: 1px solid blue;}
</style>
</head>

<body>
<div id="Outer">
<div id="Inner">
<p>MainMainMainMainMain</p>
<p>MainMainMainMainMain</p>
<p>MainMainMainMainMain</p>
<p>MainMainMainMainMain</p>
<p>MainMainMainMainMain</p>
<p>MainMainMainMainMain</p>
</div>
</div>
</body>
</html>

You don't need to absolutely position the body and your width and padding was causing your body to be 100% wide plus 42px padding.

Lance

10:24 pm on Aug 4, 2004 (gmt 0)

10+ Year Member



That's close...

With these changes, #Outer no longer extends to 42px above the bottom of the viewport and the scroll bars move back out to the HTML element. In NN, there are no scroll bars at all.

Lance

12:41 pm on Aug 5, 2004 (gmt 0)

10+ Year Member



Using some of Reflection's modifications, I came up with the code below. This is now so close. The last remaining problem is that #Outer extends below the viewport in NN. Everything else works exactly right. Even in IE in both compliant and quirks modes (imagine that!).


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html>
<head>
<title>Test</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
HTML {
BORDER: 0px;
HEIGHT: 100%;
PADDING: 42px;
OVERFLOW: hidden;
}
BODY {
HEIGHT: 100%;
MARGIN: 0px;
}
#Outer {
BORDER: 1px solid red;
HEIGHT: 100%;
OVERFLOW: auto;
}
#Inner {
BORDER: 1px solid blue;
}
</style>
</head>

<body>
<div id="Outer">
<div id="Inner">
<p>Interesting, Flashy and Unique Content Goes Here</p>
<p>Interesting, Flashy and Unique Content Goes Here</p>
<p>Interesting, Flashy and Unique Content Goes Here</p>
<p>Interesting, Flashy and Unique Content Goes Here</p>
<p>Interesting, Flashy and Unique Content Goes Here</p>
<p>Interesting, Flashy and Unique Content Goes Here</p>
</div>
</div>
</body>
</html>

Lance

4:07 pm on Aug 5, 2004 (gmt 0)

10+ Year Member



As much as I would have liked to avoid it, there was a trivial javascript work-around for the sizing problem. I will post it here for posterity, to close out this thread unless someone can come up with a purely CSS solution.


<script type="text/javascript">
<!--
if (navigator.appName == "Netscape") {
window.onload=SizeOuter;
window.onresize = SizeOuter;
}

function SizeOuter() {
document.getElementById("Outer").style.height
= (document.body.clientHeight - 84) + "px";
}
//-->
</script>


This script inserted into the last version of the code in my previous posting, as is, will cause NN to render the page the same as IE does.

Thanks, everyone, for your help.