Bri*_*n J 1 html css cell word-break
我在表格上设置了 table-layout: fixed;,但每个单元格内的单词都被分成了新行。
Eg:
Applicatio
n
Instead of:
Application
Run Code Online (Sandbox Code Playgroud)
我确实尝试了按照此处建议white-space: nowrap;添加但无济于事的解决方案
问题: 如何防止固定布局表格单元格中的断字?
表格布局:
<table id="escalation" class="table table-striped table-bordered" cellspacing="0">
<thead>
<tr>
<th style="display:none">ID</th>
<th>RID</th>
<th>Asset Name</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td class="td-limit">102345</td>
<td class="td-limit">Application Testing Break</td>
</tr>
</tbody>
</table>
Run Code Online (Sandbox Code Playgroud)
CSS:
#escalation {
table-layout: fixed;
}
#escalation th {
overflow: auto;
font-size: 10px;
color: #000000;
border-right: 1px solid #7591ac;
}
.td-limit {
overflow: auto;
font-size: 11px;
max-width: 220px;
overflow: hidden;
word-wrap: break-word;
}
Run Code Online (Sandbox Code Playgroud)
将 CSS 应用于word-break:keep-all单元格。
table { width:100px; border:1px solid black; }
th, td { word-break:keep-all; border:1px solid black; }Run Code Online (Sandbox Code Playgroud)
<table id="escalation" class="table table-striped table-bordered" cellspacing="0">
<thead>
<tr>
<th style="display:none">ID</th>
<th>RID</th>
<th>Asset Name</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td class="td-limit">102345</td>
<td class="td-limit">Application Testing Break</td>
</tr>
</tbody>
</table>Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6301 次 |
| 最近记录: |