tiger0516
asked on
Fixed width & wrap text
Hi there,
I have a table and one TD's width is 160 px. I want to set this TD's width fixed. I have set its width to 160 in CSS but if I type aaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa aaaaaaa (a very long text), then the width of the TD will expand as well. I want to wrap such kind of long text (it is because that I have RSS feeds (news) here. Some news' titles are longer than 160 px.) so that no matter how long do I input, the TD always has fixed width and will wrap the long text to multi-lines of text.
I tried but do not get through. Any help? Thanks a lot.
I have a table and one TD's width is 160 px. I want to set this TD's width fixed. I have set its width to 160 in CSS but if I type aaaaaaaaaaaaaaaaaaaaaaaaaa
I tried but do not get through. Any help? Thanks a lot.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Tiger, word wrap will cause text to move to another line when there is more text than the width of the container will fit. It wraps the text at a logical break in the text, i.e. a space or hyphen. Your example is a little unrealistic because you have no spaces or hyphens. If you try the same with some Lorem Ipsum you will find it behaves like you would expect. It is highly unlikely you will ever have that many characters entered with out a space or hyphen. Try this in your TD:
"Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Vestibulum suscipit tortor vitae lorem. Proin id urna non magna aliquam nonummy. Pellentesque molestie, ipsum sed lacinia porttitor, nunc velit volutpat elit, quis volutpat est felis ac lacus. Quisque sed purus sollicitudin urna convallis convallis. Maecenas eros nunc, rutrum pharetra, rhoncus eu, dapibus cursus, nulla. Praesent varius sagittis tortor. Nulla suscipit. Pellentesque vehicula turpis in nulla. Maecenas sed nisl. Sed ultricies nulla quis enim."
"Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Vestibulum suscipit tortor vitae lorem. Proin id urna non magna aliquam nonummy. Pellentesque molestie, ipsum sed lacinia porttitor, nunc velit volutpat elit, quis volutpat est felis ac lacus. Quisque sed purus sollicitudin urna convallis convallis. Maecenas eros nunc, rutrum pharetra, rhoncus eu, dapibus cursus, nulla. Praesent varius sagittis tortor. Nulla suscipit. Pellentesque vehicula turpis in nulla. Maecenas sed nisl. Sed ultricies nulla quis enim."
ASKER
Thanks folks.
I figured out a "silly" way to do that. I added two images (height =1 px) to TDs.
I figured out a "silly" way to do that. I added two images (height =1 px) to TDs.
You could also use serverside language to wordwrap words, or use css overflow:hidden to fix the cells width and don't show the parts that don't fit.
-r-