开发者

How Facebook deals with text overflow?

开发者 https://www.devze.com 2023-02-01 07:18 出处:网络
I\'m doing a comments system, but there\'s something that keeps bugging me. For an example when I post a comment that contains 300 symbols without spaces between them it will overflow the commentbox.

I'm doing a comments system, but there's something that keeps bugging me. For an example when I post a comment that contains 300 symbols without spaces between them it will overflow the commentbox. Then I use

overflow:hidden

but that isn't exactly what I want. Wh开发者_StackOverflowen I try the same experiment in Facebook comment, instead of overflowing and hiding, the whole string would be shown and will be somehow separated on new lines. How can I do this?


They are probably using word-wrap: break-word;.

As you can see from the link, it is supported in all major browsers.


Try this in your textarea tag

<textarea wrap="soft">

or this..

<textarea wrap="hard">

or you can use css to do it

textarea {
  word-wrap: break-word;
}
0

精彩评论

暂无评论...
验证码 换一张
取 消