你如何用   包装内容?

Nis*_*ant 4 html css web

我有一些内容, 但它没有正确包装。所以我唯一的解决方案是使用word-break: break-all但是它也会拆分这个词。我猜这 就像一封信一样对待?那么有没有一种方法可以 与字母不同地处理,这样它就可以被打破,但不能像这样的词一样?

table{
  table-layout: fixed;
  border: 1pt solid;
}
.wrapme{
  white-space: wrap;
  word-wrap: break-word;
  word-break: break-all;
}
Run Code Online (Sandbox Code Playgroud)
<div class="wrapme">
  <table>
    <tbody>
      <tr>
        <td>
          LoremIspum&nbsp;LoremIspum&nbsp;LoremIspum&nbsp;LoremIspum&nbsp;LoremIspum&nbsp;LoremIspum&nbsp;LoremIspum&nbsp;LoremIspum&nbsp;LoremIspum&nbsp;LoremIspum&nbsp;LoremIspum&nbsp;LoremIspum&nbsp;LoremIspum&nbsp;LoremIspum&nbsp;LoremIspum&nbsp;LoremIspum&nbsp;LoremIspum&nbsp;LoremIspum&nbsp;LoremIspum&nbsp;LoremIspum&nbsp;LoremIspum&nbsp;LoremIspum&nbsp;LoremIspum&nbsp;LoremIspum&nbsp;LoremIspum&nbsp;LoremIspum&nbsp;LoremIspum&nbsp;LoremIspum&nbsp;LoremIspum&nbsp;LoremIspum&nbsp;LoremIspum&nbsp;LoremIspum&nbsp;LoremIspum&nbsp;LoremIspum&nbsp;LoremIspum&nbsp;LoremIspum&nbsp;LoremIspum&nbsp;LoremIspum&nbsp;LoremIspum&nbsp;LoremIspum&nbsp;
        </td>
      </tr>
    </tbody>
  </table>
</div>
Run Code Online (Sandbox Code Playgroud)

请看这里https://jsfiddle.net/j6hpovbo/

之间的区别&nbsp;,并" "在解释什么是之间的区别“&NBSP;” 和 ” ”?

Moo*_*oob 5

在渲染之前转换数据。从外部源获取它后,只需执行字符串替换以替换&nbsp;为实际空间即可。您可以在服务器端或客户端执行此操作。服务器端可能是最好的,但这里有一个基本的 JavaScript 解决方案:

var tds = document.querySelectorAll("td");
for (i = 0; i < tds.length; ++i) {
  tds[i].innerHTML = tds[i].innerHTML.replace(/&nbsp;/g, " ");
}
Run Code Online (Sandbox Code Playgroud)
<table><tr><td>LoremIspum&nbsp;LoremIspum&nbsp;LoremIspum&nbsp;LoremIspum&nbsp;LoremIspum&nbsp;LoremIspum&nbsp;LoremIspum&nbsp;LoremIspum&nbsp;LoremIspum&nbsp;LoremIspum&nbsp;LoremIspum&nbsp;LoremIspum&nbsp;LoremIspum&nbsp;LoremIspum&nbsp;LoremIspum&nbsp;LoremIspum&nbsp;LoremIspum&nbsp;LoremIspum&nbsp;LoremIspum&nbsp;LoremIspum&nbsp;LoremIspum&nbsp;LoremIspum&nbsp;LoremIspum&nbsp;LoremIspum&nbsp;LoremIspum&nbsp;LoremIspum&nbsp;LoremIspum&nbsp;LoremIspum&nbsp;LoremIspum&nbsp;LoremIspum&nbsp;LoremIspum&nbsp;LoremIspum&nbsp;LoremIspum&nbsp;LoremIspum&nbsp;LoremIspum&nbsp;LoremIspum&nbsp;LoremIspum&nbsp;LoremIspum&nbsp;LoremIspum&nbsp;LoremIspum&nbsp;
</td></tr></table>
Run Code Online (Sandbox Code Playgroud)