HTML自动换行不起作用?

Luk*_*uke 3 html css enter

我声明了width,margins但不知怎的,我的线条没有被自动换行包裹.

在此输入图像描述

编辑:我找到了原因.这是因为单词之间没有空格:

teest teest teest teest teest teest teest teest teest teest teest teest teest teest teest teest teest teest teest teest teest teest teest teest teest teest teest teest teest teest teest teest teest teest teest teest teest teest 
Run Code Online (Sandbox Code Playgroud)

msw*_*zcz 6

文本所在的元素应该具有css声明:

div {
    display: block;
    width: 200px; /*based on how much width this div should have*/
}
Run Code Online (Sandbox Code Playgroud)

如果它不起作用尝试做:

div { word-wrap: break-word } 
Run Code Online (Sandbox Code Playgroud)


小智 5

一项一项地尝试,对某些情况一定有帮助:

p{
    display: block; /* or inline-block, at least its a block element */
    width: 100px; /* or width is certain by parent element */
    height: auto; /* height cannot be defined */
    word-break: break-all; /*  */
    word-wrap: break-word; /* if you want to cut the complete word */
    white-space: normal; /* be sure its not 'nowrap'! ! ! :/ */
}
Run Code Online (Sandbox Code Playgroud)