tags:

views:

48

answers:

4
+1  Q: 

Stretching TD's

I have a layout where I need tabs at the top, and content to fill the rest of the space. So to make the bottom content div stretch I would need to have:

style="height:100% - 20px;"

Where 20px is the height of my tabs. Obviously that code isn't valid but it illustrates my point. So what I tried next was a table where the td in the fist tr had a set height(20px) and the td in the bottom row had no height set. The table was set to 100% both ways. And this does work, the bottom td stretches to fill. However as soon as I put the code in the project I am working on it doesn't work, and this is because of the doctype the project is using(which I cannot change):

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;

The reason I say it doesn't work is that inside that content td there is a div set to 100% width and height, and unless the td its in has a defined height it doesn't seem to be able to see what 100% is, and simply adjusts the the minimum size it can be according to its content.

It doesn't need to be a table layout, i would prefer div's actually - but either way.

Thanks

A: 

AS far as I understood your question, using a table for anything other than tabular data is a serious no go area.

Check out this Dynamic Drive script for tabbed content article, it might help you out a lot :)

Edit:

<div>
    <h4>Heading</h4>
    <div>

        <ul>
            <li><a>Tab</a></li>
            <li><a>Tab</a></li>
            <li><a>Tab</a></li>
        </ul>

        <div>Content for Tab 1</div>
        <div>Content for Tab 2</div>
        <div>Content for Tab 3</div>

    </div>

</div>

I believe this is a much better way to lay it out, then it's all wrapped in one div that can define it's own height :)

Kyle Sevenoaks
Unfortunately no, that doesn't help. My question is not about the tabs. I need this:<div>Header/tabs here. Set height</div><div>Content here. This div must take up the rest of the page</div>
Matt
A: 

Try setting the height of the tr elements instead of the td (in IE6 it still won't work).
Or try something like this:

<style type="text/css">
    html, body, .wrapper {
        height: 100%;
        width: 100%;    
        margin: 0;
    }
.head {
        height: 20px;
    }
</style>
<div class="wrapper">
    <div class="head">header</div>
    <p>content</p>
</div>
Adam
A: 

I don't know if that's what you're looking for (since I don't really understand your needs, and you got so many jQuery addons for that...)

did you try

<table width="100%" height="100%">
    <tr style="height:20px; display:block;">
        <td>pwet</td>
        <td>test</td>
    </tr>
    <tr style="height:100%;width:100%;">
        <td style="background:red; width:50%;"></td>
        <td style="background:blue; width:50%;"></td>
    </tr>
</table>

EDIT : Since you're using table, the td's from the first tr should be a th and the first tr should be wrapped with a thead

Chouchenos
+1  A: 

Does this help?

http://www.themaninblue.com/writing/perspective/2005/08/29/

I know it's mainly to do with a footer but a side-effect of that is to stretch the content to 100% height.

James McCormack
Perfect, thanks!
Matt