javascript - 文本未环绕在 div 元素内

标签 javascript css html whitespace

我已经尝试了所有我能找到的 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-breakwidth

#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/

相关文章:

javascript - 更改数据格式 yyyy/mm/dd - HH :MM:SS to mm/dd/yyyy - HH:MM:SS in JavaScript

javascript - 分解 Javascript 数组数据

javascript - Bootstrap 导航栏无法正确折叠

css - 如何在 Bootstrap 中裁剪 GoogleAPI 二维码图像?

jquery - 将 html 内容加载为 json

JQuery - 复选框不检查(视觉上)

javascript - node.js 无法从 mongoexport 读取 json

jquery - Laravel-在选择时更改CSS页面样式

html - 没有文本区域的多行文本框

javascript - 在reactjs中创建一个网格