CSS溢出自动

时间:2011-04-13 09:31:12

标签: javascript css css3 overflow

您好我在我的网页上做评论框,以便我正在对该评论框进行验证,不允许用户输入空评论,并且评论sholud不大于255个字符它一切正常但是当我输入评论就像这意味着

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaakjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj

这个字符串溢出了评论框div,即它就像一条直线 我用过css属性overflow:auto;但我需要的是它应该像这样显示。它应该拆分字符串

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaakjjjjjjjjj
jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj

例如:当我发表评论The p element has both line boxes and a child box for the q element, which is a block-level element. The line boxes before the q are wrapped in an anonymous block-level box and so are the line boxes after the q. The resulting tree of boxes might be as fol

它正确......它应该是这样的

2 个答案:

答案 0 :(得分:9)

您需要的是CSS word-wrap: break-word;。它在浏览器中得到广泛支持。

word-wrap on CSS3.info

word-wrap: break-word

答案 1 :(得分:2)

您可以使用CSS3属性来解决您的问题:

.text_wrap {
  word-wrap: break-word;
}