Forum Moderators: open

Message Too Old, No Replies

Yet Another Table Height 100% Issue

         

Alec

12:46 am on Apr 16, 2007 (gmt 0)

10+ Year Member



This is driving me nuts.

I realize that several variations of the table height 100% issue have been discussed ad nauseum on the web, but I haven't found much discussion of this particular variation.

This is a simplification of what I'm actually trying to accomplish, for the sake of example.

Consider the following:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Untitled Page</title>
</head>
<body>
<table border="1">
<tr>
<td style="height: 100%;">
<table border="1" style="height: 100%;">
<tr>
<td>foo</td>
</tr>
</table>
</td>
<td>
<div style="height: 200px;">bar</div>
</td>
</tr>
</table>
</body>
</html>

In Firefox 1.5.0.11, the height of the "foo" table expands to 100% of the containing table.

In IE 7.0.5730.11, it doesn't.

What's up with that?

I know that setting an absolute height on the parent table will cause the "foo" table to expand to 100% height in IE. But, that doesn't suit my purposes. I want the height of the parent table to be determined by the height of the "bar" content, and have the "foo" table fill the height accordingly.

Is this possible?

Thanks.

JAB Creations

4:53 pm on Apr 16, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I've tried a few things with IE6 without success. It's IE: expect this sort of thing. :( You're not using this as part of a tabular page layout I hope?

You could try min-height as IE7 should support this.

- John

[edited by: JAB_Creations at 4:54 pm (utc) on April 16, 2007]

Alec

7:23 pm on Apr 16, 2007 (gmt 0)

10+ Year Member



Yes, I'm using a tabular layout. I've done a few simple div based layouts before, but for more complicated layouts I find that tables are much more intuitive and predictable. I'm usually working to a deadline, so I don't have much time to mess around. Every time I've tried to do a complicated div based layout, I've given up in frustration, despite having read several good primers on the box model, etc. Whereas with tables, I can much more consistently achieve what I need in a fraction of the time. Purist arguments aside, tables get the job done. I also work with several other web developers - very competent people - who feel the same way. For most people, tables just make sense, and seem to mirror the way people think about layout. Floating and clearing divs - wha? I sometimes think we should just rename the "table" tag to "layout" to avoid the politics, and voila! We now have an intuitive, robust, predictable method of creating layouts.

Having said that, I'm open to suggestions about how to make this layout using divs. :)

Here's a pic of what I'm trying to do:
<screenshot removed>

What we're looking at is the left edge of the main content area, with a gradient in the background. You'll notice a dropshadow over that gradient. Let's ignore the dropshadow for now. The main content area is horizontally centered, and a fixed-width, but with variable height - height is determined by the content. The vertical gradient needs to originate from the vertical centerpoint of the content area, and fade out to the top and bottom of the content area.

The way I would have approached this layout before XHTML rendering broke things, is to have a "layout" table with 3 columns. The first and last columns each contain a "gradient" table. The center column contains the content. Each gradient table extends to 100% of the height of the layout table. That way, the content is determining the height of the layout table, and the gradient table is just scaling to fill the space. Each gradient table would have 3 rows. The top and bottom rows would contain background images of the fade outs. The middle row would be a solid color, and would be vertically stretchable. That way, as the content grows vertically, the middle gradient row stretches, but the top and bottom "fadeouts" remain a fixed height.

Any ideas? I'm happy to provide more detail, if needed.

Oh, and setting min-height: 100% on the "foo" table didn't have any effect in IE 7.

Thanks again.

[edited by: encyclo at 7:28 pm (utc) on April 16, 2007]
[edit reason] no screenshots please, see forum charter [/edit]