views:

127

answers:

3

I've got a table on a webpage, with (say) 8 columns, and it's worked just fine until recently...

A user registered with an email address for a display name (not a huge issue, but the email is massive). Now, as one of the columns is a 'reported by' containing username, any pages with said user on them now have a massive 'reported by' column...

I should also emphasise, the table width was 100% (minus a 'margin') prior to this issue, and it worked just fine).

Is there a clever way to introduce a line break on a '.' or an '@'? Alternatively, how do people normally get around this? Interesting solutions to this annoying problem are welcomed!

Thanks in advance,

+1  A: 

You could set a max-width on the column and overflow:scroll or even overflow:hidden.

RegDwight
That is a nice solution and probably the best I'll get, I'll implement it for the time being and see how it goes. I suspect overflow:hidden will be the nicest way. Thanks
Dave
After testing this, further complications arise :( Each column has a filter (in the form of a drop down menu) at the top, and they now get clipped... If I could (somehow) shorten the drop down, so I could see the \/ arrow, then I could get away with this I'm sure....
Dave
Hard to say without seeing the code... Is the content of the filter menu dynamic? If not, then you could probably get away with simply increasing the max-width (in em rather than px, so that the menu still fits if its font size changes).
RegDwight
Sounds good Reg, I'll give that a bash!Thanks,
Dave
A: 

Use the table-layout css property.

table-layout: fixed;

http://www.quirksmode.org/css/tables.html#tablelayout

emmychan
This doesn't work for me, as the width of one row within the table is bigger than the screen - there are 12 columns and two contain massive non-broken entries.
Dave
+2  A: 

When you generate your html table content code, truncate every content extracted from your database to a maximum width. Your truncating function can easily add a tooltip giving the full label.

Alternatively, do this in javascript on pageload. Parse every table cell and truncate the content if it's too large. It's not as nice as server-side truncating, though.

The upside is that you can give the full label in a tooltip, append '...' to let the user know the label is truncated, etc.

Alsciende
Nice idea, I should of thought of truncating the data from the database call tbh! The only thing stopping this being perfect is the 'filter' row of the table, used for the obvious, which keeps the table widths, or risks affecting the filter functionality. I'm sure I'll be able to russle somethign together to get around that though! Cheers for hte input
Dave