Okay, so it seems, for some reason (I might be doing it wrong, obviously), that I have some problem wrapping continuous lines, using Asp.net.
Let's say I have 800 pixels worth of the "m" character, well, my table cell gets extended to that length. I don't want that, I want the cell to automatically break the continuous line after 300px.
To do that, I tried to apply the word-wrap:break-word css style. Didn't work. Now what?
Do I parse the line, to insert explicit linebreaks after a certain number of characters? That doesn't seem very clean to me. Any ideas?
-
Do you really have 800px of "m" or is that just test data? If that is real data then yes you will have to create some whitespace in there somewhere. HTML parsers don't wrap text that overflows an element unless that text has spaces in it that allow the text to be wrapped.
If the m's are a test string and do not reflect real data I would suggest you use some dummy text (like Lorem Ipsum) to test with as it has spacing more akin to regular text.
MrZombie : Actually, it's not "my" test data. My boss tests fields in such a way that he tries to break my application, to test the limits of stuff.I guess I could impose a conditional linebreak after an average length of non-breaky character stuff. Thanks for your help though. I was wondering whether it was possible or not to force that linebreak, as the "word-wrap" does. And somehow it works in IE7 on a div, but not on a TD... Might just try something, for the heck of it.MrZombie : After a trial: No, I can't do that either. Tried to insert the "wordwrap:break-word" inside the style of a div, but it dislikes that too. Why does it work in a simple page but not embedded in a table? -
You can insert a
<wbr>
(little known html element) every few m's. It's not 100% compatible with everything, but it works in most browsers:<wbr>
(word break) means: "The browser may insert a line break here, if it wishes." It the browser does not think a line break necessary nothing happens.So you would do something like this:
mmmmmmmmm<wbr>mmmmmmmmmm<wbr>mmmmmmmmmmm<wbr> (etc.)
Here's some more info: http://www.quirksmode.org/oddsandends/wbr.html
MrZombie : I think "" should work too, in theory... I'll try that.Keltex : will also work, but it comes out as a hyphen whereever a break occurs. So as long as you don't mind that...Chris Lively : +1 because I had never heard of that tag before.
0 comments:
Post a Comment