dbMe
asked on
Break text, not layout
I have some long text that is breaking my css layout. How can I make it wrap when it gets to the right side of its box NO MATTER WHAT? I've tried using vbscript (asp) to insert line breaks every 100 characters, but that's not working so well. I could use JavaScript. The ideal solution would be a css property or something. Thanks!
Here's an example (gotta love the line art)
The 3 column css layout
------------------
| | | |
| | | |
| | | |
| | | |
------------------
With long text:
------------------
| |BREAK!
| | ____
| | | |
| | | |
----- | |
-----
------------------
Here's an example (gotta love the line art)
The 3 column css layout
------------------
| | | |
| | | |
| | | |
| | | |
------------------
With long text:
------------------
| |BREAK!
| | ____
| | | |
| | | |
----- | |
-----
------------------
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Anything like that will be a little hackish I'm afraid and somewhat estimatable.
You'll probably need to estimate the amount of characters per line, and you'd have to give a fixed font size, like 12pt or something so the user can't change it.
var hl=75; //say there's 75 characters per line.
function breakWord(wrd) {
var wrdArray=new Array;
for (var i=0;i<Math.ceil(wrd.length /75);i++) {
wrdArray[i]=wrd.substr(75* i,75*(i+1) );
}
return wrdArray;
}
You'll probably need to estimate the amount of characters per line, and you'd have to give a fixed font size, like 12pt or something so the user can't change it.
var hl=75; //say there's 75 characters per line.
function breakWord(wrd) {
var wrdArray=new Array;
for (var i=0;i<Math.ceil(wrd.length
wrdArray[i]=wrd.substr(75*
}
return wrdArray;
}
ASKER
Thanks a lot. I also found this link on ASP101.com: http://www.asp101.com/samples/viewasp.asp?file=wordwrap.asp. It looks like it'll do the trick, although I think you're right, anything like that would be a little hackish.
ASKER
That was an easy one eh?
Hopefully, things like these will be fixed in the future, well, glad to help ;)
Somewhat :)
ASKER
Thank you kindly. How could I do this in JS (in the event that I have do do this for a non-native IE crowd)?