Table is extending too far with long strings and won't go to new line
So I'm having a problem and I can't think of a fix for it.
Im dealing with a situation where users can post comments and it is displayed in a table. This table's width is set by 100% and fits nicely with the site's design. However if users post a comment with words that have a lot of characters
(ex: mynameisblahblahaaaaa!!!!!!!!!)
the table will extend over it's container to fit the long string. With normal size words it just reaches the 100% width a开发者_Python百科nd goes down to a new line.
I realize I can do a fixed table width but that would involve using pixels and not a % but I feel using pixels would mess up the site on odd dimension browsers...
Is there anyway to fix this?
Here is an example of what I'm talking about:
You can use the CSS word-wrap
property set to word-wrap: break-word
to instruct the browser to break in between words.
Also, don't use a table for what you're doing -- tables are intended only for tabular data.
You need to set table-layout:fixed
in you css
精彩评论