为了账号安全,请及时绑定邮箱和手机立即绑定

HTML表中的单词包装

HTML表中的单词包装

慕的地6264312 2019-06-25 13:09:14
HTML表中的单词包装我一直在用word-wrap: break-word将文本包装在divS和span然而,它似乎在表单元格中不起作用。我有一张桌子width:100%,有一行和两列。列中的文本,尽管采用上述样式word-wrap不包。它会导致文本超出单元格的界限。这种情况发生在Firefox、GoogleChrome和InternetExplorer上。来源如下:td {  border: 1px solid;}<table style="width: 100%;">  <tr>    <td>      <div style="word-wrap: break-word;">        Looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong word      </div>    </td>    <td><span style="display: inline;">Short word</span></td>  </tr></table>上面的长单词比我的页面的边界要大,但它不会与上面的HTML断绝关系。我已经尝试了以下添加的建议text-wrap:suppress和text-wrap:normal但两者都不起作用。
查看完整描述

3 回答

?
红颜莎娜

TA贡献1842条经验 获得超12个赞

以下内容在InternetExplorer中适用于我。注意添加了table-layout:fixedCSS属性


td {

  border: 1px solid;

}

<table style="table-layout: fixed; width: 100%">

  <tr>

    <td style="word-wrap: break-word">

      LongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongLongWord

    </td>

  </tr>

</table>


查看完整回答
反对 回复 2019-06-25
?
波斯汪

TA贡献1811条经验 获得超4个赞

<td style="word-break:break-all;">longtextwithoutspace</td>

<span style="word-break:break-all;">longtextwithoutspace</span>


查看完整回答
反对 回复 2019-06-25
?
精慕HU

TA贡献1845条经验 获得超8个赞

很长的机会,但要反复检查火虫(或类似的)您不会意外继承以下规则:

white-space:nowrap;

这可能会覆盖指定的断行为。


查看完整回答
反对 回复 2019-06-25
  • 3 回答
  • 0 关注
  • 326 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信