我已经尝试了所有我能找到的 CSS 设置,但是我无法让这个 div 中的文本换行!我将不胜感激,因为这是我近 10 年来第一次使用 HTML。这是我最近的尝试:
#text0 {
word-break: break-word;
max-width: 500px; width: 500px;
word-wrap: break-word;
overflow: hidden;
white-space: pre;
background-color: #afed67;
}
<div id="text0">
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scramble
it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</div>
顺便说一句,这一切都必须进入 Wordpress 页面,我知道他们可能对 CSS 和 JavaScript 很挑剔。
最佳答案
检查这个片段。您只需要 word-break
和 width
#text0 {
word-break: break-word;
width: 500px;
background-color: #afed67;
}
<div id="text0">
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scramble
it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</div>
关于javascript - 文本未环绕在 div 元素内,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38736494/