段落自动换行

use*_*703 4 html css text

在DIV我把段落但是当文本比div更长时,它不会创建新行但是在DIV之外.我尝试用: -moz-hyphens:auto; -ms-hyphens:auto; -webkit-hyphens:auto; hyphens:auto; word-wrap:break-word;但它不起作用.任何建议?

这是div的代码:

<div id="content">
<p id="test">tfufygigighfetefddddddddddddsssssssssssssssssssssssssssssssssssssssssssfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff</p>
</div>
Run Code Online (Sandbox Code Playgroud)

div的css代码:

#content {
float:left;
position:absolute;
background-color:#D4D3D0;
height:500px;
width:80%;
}
Run Code Online (Sandbox Code Playgroud)

和段落的CSS:

p.test {
-moz-hyphens:auto;
-ms-hyphens:auto;
-webkit-hyphens:auto;
hyphens:auto;
word-wrap:break-word;
}
Run Code Online (Sandbox Code Playgroud)

小智 7

我要出去了!但我相信你需要放入word-wrap: break-word;div css,而不是<p>css.这个对我有用!

编辑:

哦等等,我能看出你做错了什么.<p>标签的名称不是p.test它的#test!

  • 对于现在看到它的人来说。看来 word-wrap 已更改为overflow-wrap,因此代码将是:overflow-wrap:break-word; 请参阅 https://developer.mozilla.org/en-US/docs/Web/CSS/overflow-wrap 了解更多信息。 (2认同)

小智 6

添加word-wrap: break-word;#content

您还可以从p元素中删除这些样式.