tags:

views:

37

answers:

2

I need to create a chat layout that uses all the available space and scales nicely, but has few fixed sizes.

Here's the structure:

<table style="width: 100%; height: 100%">
    <tr>
        <td></td>
        <td style="width: 200px; background: red;"></td>
    </tr>
    <tr>
        <td style="height: 100px; background: blue"></td>
        <td></td>
    </tr>
</table>

However, I want to place a lot of content in the first table cell and I want it to scroll, so it won't expand the table.

Is it possible to make it overflow properly, without having a fixed height for the cell? Simply adding overflow: auto doesn't seem to work.

PS. I hate tables, but can't figure out a very clean and cross-browser way to do a layout like this with divs and css. If someone can come up with one, I'll gladly use it.

+1  A: 

One way to achieve is use put all content in div element and set div overflow property to auto

<table style="width: 100%; height: 100%">
    <tr>
        <td>
         <div style="overflow:auto;">
              //your contain 
          </div>
        </td>
        <td style="width: 200px; background: red;"></td>
    </tr>
    <tr>
        <td style="height: 100px; background: blue"></td>
        <td></td>
    </tr>
</table>
Pranay Rana
Tried this on firefox and chrome, doesn't seem to work. The table still grows when I add a lot of content and the scroll doesn't appear.
Ezdaroth
provide width and height to div
Pranay Rana
Using height: 100% on the container div seems to work fine in chrome, but the problem persists in firefox.
Ezdaroth
use min-height for the div like div{min-height:300px;height:auto!important;height:300px;}
Pranay Rana
Still doesn't seem to work for firefox. I can't have fixed height for the cell, since I want the table to fill all the available space no matter where I place it and scale properly if the container's size changes.
Ezdaroth
I think you should try the `max-height:;` property, in the table as in the div.
Tae
+1  A: 

An alternative if your content shouldn't actually even be in a table is to use a CSS grid system, such as 960.gs or Nicole Sullivan's "OO-CSS".

You'd want to divide a container into however many grids you needed and these lend themselves much better to CSS decoration. They're much more flexible and simple to use.

Phil.Wheeler