tags:

views:

133

answers:

1

Hi,

I'm trying to do the following: http://www.pastebin.org/113337

I'm wondering why the scrolling won't take place? It just stretches the table. Try running the code with and without white-space: nowrap and see how it differs. Whenever I apply nowrap my table gets stretched. How do I avoid this?

+2  A: 

I'm pretty sure that's just how tables work; they stretch when there's too much content in one of their cells. Try putting a <div> inside your <td> and apply the width and overflow properties to that instead.

Addendum:

Your table has a CSS width property of 150px while the div has a percentage, %100. Try giving the <div> a non-percentage width...

<table>
    <tr>
        <td>
            <div style="150px;">
                <!-- wtv -->
            </div>
        </td>
    </tr>
</table>

Or try putting the whole <table> in a <div> with a fixed width...

<div style="width:150px">
    <table>
    <!-- wtv -->
    </table>
</div>

... lastly, I'd advise that you put your CSS in an external .css file ;)

LeguRi
I tried that. See my edited question, I put a div inside the td, but results are the same.
rFactor
It does work fine when I set the width for the div manually, but I'd like to avoid that. That's why all the hassle. I use jQuery to change the table position and size, and I would like to only change one value, not a bunch of values. If that's not possible, then I guess I just have to manually calculate and update the size of the inner div, too, which makes skinning for this system much harder I'm afraid.
rFactor
I think I'm going with that inner div approach and then just altering its size as well as the size of the table.
rFactor
How about if you use the `class` attribute and external CSS rules?
LeguRi