newinjs
newinjs

Reputation: 140

Text overlap div

I have a comment box, if they enter long one word, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"

the box will break(text out of div), i have used overflow:hidden but my friend want it to break like normal text.

Any idea how to fix ?

Upvotes: 0

Views: 940

Answers (2)

nikc.org
nikc.org

Reputation: 16952

In order for overflow to hide content that is larger than it's containers' dimensions, the container must have a set width. But even so, CSS doesn't break long words. (Except for IE, which has the word-wrap: break-word instruction. Further reading.)

If you're using some sort of server side processing (I assume you are), you could manipulate text content by breaking up long words at a preset length and thus avoid overflowing.

Upvotes: 3

Mitch Dempsey
Mitch Dempsey

Reputation: 39869

You need to use whatever server language you have to devise some way to break the string up. You could use a combination of regex (to check for long unbroken strings) and then combine it with some string split function in order to insert some newlines or something.

Upvotes: 0

Related Questions