Jump to content

Forced Wrapping of Text


Recommended Posts

Is it possible to set an attribute for a div element so that if the text inside of it has a string that is so long (without <br> or whitespace) that it will "break" the line to prevent it from displaying outside of the div? as it stands, if a line entered is too long or is contained within a <pre> tag, it goes right outside of the defined border area.If a concrete example of the page is needed, I'll send the link in a private message so you can look at the problem that is occurring and the circumstances in which I'd like to fix it.Any alternative solutions are welcome, but I'd like to avoid scripting if possible.Thanks for the help, -Nago

Link to post
Share on other sites

Overflow hidden will, as I understand, actually mask the excess text- the text that is "overflowing" is important and needs to be shown, but I would have liked to do it with a forced linebreak.The div element that this text is in already has a defined width- the problem is that if a string does not have whitespace in it and exceeds a certain amount of chars, it flows over the alotted border. In a short example, say this div is roughly 500px wide. If I have a word with no whitespace that now exceeds 500px, it extends PAST the border. I would manually add linebreaks for scenarios like this, but the content within this div is Automatically generated, and I don't have ways of easily modifying or controlling it.Otherwise, standard word wrap works fine. It breaks things that are too long and puts them on the next line. It's strings without whitespace that are the current problem.MadPotato: Do you have any suggestions, or otherwise a FAQ on how to accomplish an effect of that sorts?

Link to post
Share on other sites
Overflow hidden will, as I understand, actually mask the excess text- the text that is "overflowing" is important and needs to be shown, but I would have liked to do it with a forced linebreak.The div element that this text is in already has a defined width- the problem is that if a string does not have whitespace in it and exceeds a certain amount of chars, it flows over the alotted border. In a short example, say this div is roughly 500px wide. If I have a word with no whitespace that now exceeds 500px, it extends PAST the border. I would manually add linebreaks for scenarios like this, but the content within this div is Automatically generated, and I don't have ways of easily modifying or controlling it.Otherwise, standard word wrap works fine. It breaks things that are too long and puts them on the next line. It's strings without whitespace that are the current problem.MadPotato: Do you have any suggestions, or otherwise a FAQ on how to accomplish an effect of that sorts?

I've had the same problem. I tried everything to let the layout (clientside) break the words, also tried overflow: hidden etc etc. I wasn't able to solve the problem. Then I tried it serverside, with more success. I solved it using PHP's wordwrap ():wordwrap ($string, 17, "<br />\n", 1)you should also specify this in your CSS:white-space: nowrap;Maybe it's useful to your situation.
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...