Forum Moderators: not2easy

Message Too Old, No Replies

IE not getting cell heights right.

How do I get IE to do something simple?

         

Purple Martin

4:33 am on Jun 24, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I've been experimenting more with table heights. IE can't even get this simple table right. The top row should be set to 50px high, the bottom row should take up the remainder of the screen. I would have thought that was easy! Mozilla does it perfectly, IE doesn't. Copy'n'paste the short example file to see.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1">
<title>table test</title>
<style type="text/css">
html, body, table {
padding:0px;
margin:0px;
width:100%;
height:100%;
}
.short {
height:50px;
}
</style>
</head>
<body>
<table cellspacing="0" cellpadding="0" border="1">
<tr>
<td class="short">This row should be only 50px high...</td>
<td>...but in IE6 it's about 3/4 of the viewport height.</td>
</tr>
<tr>
<td>This row should expand to 100% minus 50px.</td>
<td>Of course it all works in Mozilla.</td>
</tr>
</table>
</body>
</html>

Rambo Tribble

4:56 am on Jun 24, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Interestingly, if you remove the 100% height from the table, the top td will revert to 50px. I think you may have to resort to JavaScript to determine the window height and set the second row's td's to the appropriate height.

What actually appears to be happening, is that IE, when faced with having to expand the table to 100%, is splitting the height 50/50 between the rows, then adding the 50px to the top row (via the td).

IE does seem to do a better job when you use a class on the lower td's and split the height by percentages, say 10% top 90% bottom.

Purple Martin

12:44 am on Jun 28, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



IE does seem to do a better job when you use a class on the lower td's and split the height by percentages, say 10% top 90% bottom.

Better, yes, but unfortunately still broken: if the contents of the top cell pushes it to more than 10% the bottom cell stays at 90% and doesn't get shorter to compensate, with the result that the table is now more than 100% of the viewport.

Even if I explicitly set the bottom cell and/or row to height:auto; IE still can't make the top cell an absolute height and make the bottom cell fill the remainder of the viewport.

Come on all you table-layout gurus, please let me in on the secret to a 100% high table!

createErrorMsg

4:17 pm on Jun 28, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I can't contribute anything useful to this discussion (I'm so bad with tables I eat on the floor), but I wanted to say that your thread's subtitle made my day.
:)

SuzyUK

9:38 pm on Jun 28, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Come on all you table-layout gurus, please let me in on the secret to a 100% high table!

I'm no table guru.. but the only answer I ever found was to use IE in quirks mode (doctype switch)

Suzy

Purple Martin

1:06 am on Jun 29, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks Suzy, you're right that does work - at least it does in the simple example table above. Now I've got to experiment with someone's complex nested table layout to make it work in that too.

I really don't like the idea of quirks mode, but I can't think of any other options!

Rambo Tribble

3:07 am on Jul 12, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Remember, you can force quirks mode on an XHTML document by having the appropriate xml prolog before the DOCTYPE declaration. If that helps you feel better about it.

vkaryl

3:19 am on Jul 12, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



....someone's complex nested table layout....

Ouch. Can't get them to let it go, huh? Bummer.

Purple Martin

3:29 am on Jul 12, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Ouch. Can't get them to let it go, huh? Bummer.

'Fraid not! Besides the office politics it would have caused, there simply wasn't time to rebuild it from scratch.

I ended up cheating: I ripped out the offending cell's content and stuffed it in an absolutely positioned div. I gave the div a bottom margin so there is always room for the footer row to show underneath. So now the page is mostly nested-table nightmare, with one nice neat div. It's robust in all relevant browsers, it was quick to do, and I doubt that anyone will ever notice that I cheated :)

vkaryl

3:34 am on Jul 12, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Bless you.... sometimes you just have to cheat - otherwise it's a WORSE nightmare than nested table spaghetti....