溢出包装
overflow-wrap
告诉浏览器它可以将目标元素内的一行文本分解到另一个不可破坏的地方的多行。有助于防止长字符串文本导致布局问题,因为它的容器溢出。
CSS
div {
width:100px;
outline: 1px dashed #bbb;
}
#div1 {
overflow-wrap:normal;
}
#div2 {
overflow-wrap:break-word;
}
HTML
<div id="div1">
<strong>#div1</strong>: Small words are displayed normally, but a long word like <span style="red;">supercalifragilisticexpialidocious</span> is too long so it will overflow past the edge of the line-break
</div>
<div id="div2">
<strong>#div2</strong>: Small words are displayed normally, but a long word like <span style="red;">supercalifragilisticexpialidocious</span> will be split at the line break and continue on the next line.
</div>
overflow-wrap - 价值 |
细节 |
---|---|
normal |
如果字长于行,则允许字溢出 |
break-word |
如有必要,将一个单词分成多行 |
inherit |
继承此元素的父元素值 |