html - 如何在没有的情况下打破长句
问题描述
我有一张如下表。
当我向“1111111111111111111”添加更多文本时
表格将被放大,我怎样才能打破不包含 br 或空格的文本?
<table style="width:280px">
<tr align="left" valign="top" style="font-size: 14px;">
<th align="left" style="width:100px;white-space: normal;">LEE, WING WING wrote:</th>
<th style="width:20px"></th>
<th align="left" style="width:100px;white-space: nowrap;">15-Sep-2019 12:08</th>
</tr>
<tr align="left" valign="top">
<th colspan="3" style="white-space: pre-wrap; word-wrap: break-word;width:100px">1111111111111111111111111111111111111111111111111111111111</th>
</tr>
</table>
解决方案
您应该尝试使用 CSSword-break
属性。
word-break CSS 属性设置是否在文本溢出其内容框的地方出现换行符。
table tr th {
word-break: break-word;
}
下面是一个工作示例。我冒昧地将您嵌入的样式移动到单独的 CSS 样式表中,但您可以随意在任何您喜欢的地方编写样式。
table {
width: 280px;
}
table tr {
font-size: 14px;
}
table th {
border: dotted 1px red;
width: 100px;
white-space: normal;
}
table th:last-child {
white-space: nowrap;
}
table tr:last-child th {
white-space: pre-wrap;
word-break: break-word;
}
<table>
<tr align="left" valign="top">
<th align="left">LEE, WING WING wrote:</th>
<th style="width:20px"></th>
<th align="left">15-Sep-2019 12:08</th>
</tr>
<tr align="left" valign="top">
<th colspan="3">
1111111111111111111111111111111111111111111111111111111111
</th>
</tr>
</table>
推荐阅读
- excel - 我无法更新 powerpoint VBA 上的工作表对象链接 - OneDrive 文件夹
- django - 覆盖模型中的 save() 方法以使用当前用户 Django 预填充它
- nsis - 如何在 nsis 中重新启动时移动文件
- flutter-web - flutter web项目名称、图标和描述如何处理?
- javascript - 使用 vue-resizable 调整大小的 Div
- java - Eclipse 运行错误的 java 文件
- ios - iOS - Ship Widget Extension 与部署目标 < 14 的应用程序
- python - python搜索逻辑查找列表中最后一个单词的作品
- graphql-codegen - 使用带有 Graphql 的 RTK 查询
- html - Cors 和 Onedrive