Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Difficult Question About Tables

Status
Not open for further replies.

jonbatts

Programmer
Apr 12, 2005
114
US
I have a page with a lot of tables and subtables in it. Part of the basic structure is this
Code:
<TABLE id="tbl1" style="Z-INDEX: 101; LEFT: 8px; POSITION: absolute; TOP: 8px" cellSpacing="0" cellPadding="0" width="100%" border="0">
    <TR>
        <TD id="MyTD1">Stuff1</TD>
        <TD id="MyTD2">Stuff2</TD>
    </TR>
    <TR>
        <TD colspan="2">
            <TABLE id="tbl2" width="100%">
                <TR>
                    <TD>
                        <TABLE id="tbl3" width="100%">
                            <TR>
                                <TD id="MyTD3">
                                    <TABLE id="tbl4" width="100%">
                                        <TR>
                                            <TD>Stuff3</TD>
                                        </TR>
                                    </TABLE
                                </TD>
                                <TD id="MyTD4">
                                    <TABLE id="tbl5" width="100%">
                                        <TR>
                                            <TD>Stuff4</TD>
                                        </TR>
                                    </TABLE
                                </TD>
                            </TR>
                         </TABLE>
                    </TD>
                </TR>
                <TR>
                    <TD>Stuff5</TD>
                </TR>
                <TR>
                </TR>
            </TABLE>
        </TD>
    </TR>
</TABLE>
I know this looks pretty complex, and there's a lot going on, but that's the nature of the page. Try to stay with me here. When I change the size of "MyTD1" to be "1%" or "MyTD2" to be "100%" (which is what I want to do), "MyTD3"'s width grows. Even if you're totally lost reading this, does anyone have a link to good site about advanced tables that can tell me how they interact with each other. i.e. What does the page process first, if input of the widths clash, which takes precedence, etc. Help on this specific problem, or a link to a really good site completely explaining tables would be excellent. Thanks.
 
If you give your table a style of "table-layout:fixed":

Code:
<table ... style="table-layout:fixed;">

then the widths you set will be more likely to be adhered to.

Hope this helps,
Dan



[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Foamcow. I understand that, but if I have a table whos width is 100%, such as "tbl1" above, and I set one of its cells widths ("MyTD2") to 100%, that shouldn't change the size of "tbl1". It should only cause "MyTD1" to only use as much room as it has to and allow "MyTD2" to take up the rest of the room in that row. So, because "tbl1"s width isn't changing, I don't see why the width of "MyTD3" is changing. Any other ideas?
 
Actually Dan, a fixed layout isn't what I'm looking for. I want cells to grow with the page, but I want them to grow proportionally. Thanks anyway.
 
And what kind of layout do you recommend cL?
 
a fixed layout isn't what I'm looking for. I want cells to grow with the page, but I want them to grow proportionally.

Did you try it? If your table has a width of 100%, and you specify all your column widths in percentages, they should still grow proportionally.

Dan



[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
I understand that, but if I have a table whos width is 100%, such as "tbl1" above, and I set one of its cells widths ("MyTD2") to 100%, that shouldn't change the size of "tbl1"

It will if the contents of MyTD2 are bigger than the space permitted by 100% rule applied to the cell.

For instance:
Lets assume that if you say MyTD2 has a width of 100% which, because of the size of tbl1 is, say 200px.
Then put something that is 250px wide into MyTD2.

Won't that cause MyTD1 to expand to accomodate it's content.
Wouldn't that, in turn, cause tbl1 to expand to accomodate it's content too (i.e. MyTD2).

I may be wrong as I've not used table layouts for a long time.

Foamcow Heavy Industries - Web design and ranting
Buy Languedoc wines in the UK
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top