CSS 如果文本溢出,如何使文本进入下一行?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8369819/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I make a text go onto the next line if it overflows?
提问by user784756
I tried word-wrap: break-word;
, but it separates lines mid word.
我试过word-wrap: break-word;
,但它在单词中分隔行。
采纳答案by Tieson T.
As long as you specify a width on the element, it should wrap itself without needing anything else.
只要您在元素上指定宽度,它就应该自动包装而无需其他任何东西。
回答by Serina Patterson
In order to use word-wrap: break-word
, you need to set a width (in px). For example:
为了使用word-wrap: break-word
,您需要设置宽度(以像素为单位)。例如:
div {
width: 250px;
word-wrap: break-word;
}
word-wrap is a CSS3 property, but it should work in all browsers, including IE 5.5-9.
word-wrap 是一个 CSS3 属性,但它应该适用于所有浏览器,包括 IE 5.5-9。
回答by Damathryx
word-wrap: break-word;
add this to your container that should do the trick
将此添加到您的容器中,应该可以解决问题