文本区域文本溢出
我写了一个论坛,但我遇到了一个问题...帖子中的文本溢出,它只是传递了 div,即使它有一个设定的宽度。它永远不会创建换行符。我尝试过用
替换 \r\n ,但没有成功。如果它是纯 HTML,它就不会像这样反应。文本当然是从保存在数据库中然后检索的文本区域生成的。
有什么办法可以解决我的这个问题吗?
感谢您抽出时间!
ZyteX
I have written a forum, but I've got one problem... The text from the posts overflows, it just passes the div even though it has a set width. It never creates a linebreak. I've have tried replacing \r\n with
, but with no success. If it would have been pure HTML it wouldn't react like this. The text is of course generated from a textarea which is saved in a database and then retrieved.
Is there any way of solving this issue of mine?
Thanks for your time!
ZyteX
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
纯粹的猜测,因为没有 jsfiddle 设置:
您的文本显示在具有
white-space: nowrap;
样式的区域中,或者文本中没有空格,因此不能将其拆分为多行。尝试明确设置
white-space: normal;
。Pure guess, since no jsfiddle setup:
Your text is displayed in a zone that has a style
white-space: nowrap;
OR the text has no space in it, so it cannot be splitted on multiple lines.Try setting
white-space: normal;
explicitely.尝试设置 div 的 max-width 。这应该迫使 div 不能溢出其宽度。
Try to set max-width on div. That should force that div cannot overflow its width.
不用再回答这个问题了!我通过创建一个系统来解决这个问题,其中至少需要两个单词,并且单词的长度不能超过 40 个字符。
感谢您的回答!
No need to answer this anymore! I solved it by making a system where you need to have atleast two words and where the length of the words can not be longer than 40 char.
Thanks for answering!