CSS word-wrap屬性用于將長單詞打斷并自動(dòng)換行到下一行。當(dāng)不可破壞的字符串太長而無法容納在容納盒中時(shí),此屬性用于防止溢出。
| 值 | 描述 |
|---|---|
| normal | 此屬性僅用于在允許的斷點(diǎn)處斷開單詞。 |
| break-word | 它用于打斷牢不可破的單詞。 |
| initial | 它用于將此屬性設(shè)置為其默認(rèn)值。 |
| inherit | 它從其父元素繼承此屬性。 |
<!DOCTYPE html>
<html>
<head>
<style>
p.test {
width: 11em;
background-color: #ff9900;
border: 1px solid #ffffff;
padding:10px;
word-wrap: break-word;
}
</style>
</head>
<p class="test"> In this paragraph, there is a very long word:
iamsooooooooooooooooooooooooooooooolongggggggggggggggg.The long word will break and wrap to the next line.</p>
</html>測(cè)試看看?/?輸出:
在這一段中,有一個(gè)很長的單詞:iamsooooooooooooooooooooooooooooooooooooolongggggggggggggggg.long這個(gè)單詞會(huì)折斷并繞到下一行。