如何使段落驻留​​在div中

时间:2014-09-28 20:57:03

标签: css

文字超越了div。如何强制执行不会在div之外溢出的段落?



.preview {
    background: red;
    width: 200px;
}

<div class="preview">
    <p>aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa</p>
</div>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:3)

使用自动换行:

.preview {
    background: red;
    width: 200px;
    word-wrap: break-word;
}
<div class="preview">
    <p>aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa</p>
</div>