Link to home
Start Free TrialLog in
Avatar of astromex
astromex

asked on

Stop <TD> contents pushing out table width.

How do I put a large amount of text in a <TD> without it pushing out the table cell width.

For example:
Say the cell contents are: "abcdefghijklmnopqrstuvwxyz", and my cell with is 100px
I want it to display like this with the text in the 2nd table cell:

|--------------1--------------|abcdefghijklmn||--------------3--------------|--------------4--------------|

...with the "opqstuvwxyz" being "hidden" underneath <TD>#3.

This IS possible.
I did have the code (which I viewed-source from a Microsoft site) - but I cant find it anymore.
I think I remember it using a table inside a table, or something like that...
Avatar of Batalf
Batalf
Flag of United States of America image

The only method I can think of that is crossbrowser is to use a div with overflow set to hidden.

Example:

<style type="text/css">
.width100{
    width:100px;
    overflow:hidden;
}
</style>
<table border="1">
<tr><td><div class="width100">Thissjaksdfhklajhsdfaklshdfaksljhf</div></td></tr>
<tr><td><div class="width100">0123456789012345678901234567890</div></td></tr>
</table>
Avatar of astromex
astromex

ASKER

hmmm, that sort of thing, but the example I had before supported variable TD widths - whereas your example is set to 100px.
(in other words the div with is set to 100% of the TD width, so if you resize the browser window, you can reveal more/less content)

I tried setting with the div width to % instead of px, but that didnt work - any ideas?
I remember the nested tables had a lot to do with it - each TD had a table inside it (I wish I could find the original code sample!!)
ASKER CERTIFIED SOLUTION
Avatar of bruno
bruno
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
brunobear, thats spot on. I used 100px as an example because the alphabet wouldnt fit in 100px with the EE font - but sorry I should have been more specific.

Are you guys happy to split the points, or what???
No, give brunobear the points. His comment solved your problem

Batalf
OK Batalf, Many thanks for your help!
Batalf you certainly deserved points here - I can make it up to you with some extra points in one of the PHP questions i asked.  :-)


astormex, glad we could help!