You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

固定宽度HTML表格显示锯齿状问题求助

问题诊断与修复方案

问题根源

  1. 多独立表格导致对齐失效:你把本该属于同一个表格的内容拆成了多个<table>标签,每个表格都是独立的渲染单元,哪怕列宽数值一致,浏览器也会因为每个表格的内容高度、内部换行/空元素的差异,让列对齐错位,看起来就是锯齿状。
  2. 缺少强制列宽的关键属性:没给表格加table-layout: fixed,浏览器默认会根据单元格内容自动调整宽度,你手动设的width会被覆盖。
  3. 冗余无效代码干扰:存在空的<tr>标签、未闭合的文本(比如[FI)、多余的<p>和<br>,这些都会打乱渲染逻辑。

修复步骤

  1. 合并所有表格为一个完整表格:把所有分散的<table>合并成一个,保留唯一的表头和所有数据行。
  2. 添加强制列宽属性:在表格的style里加入table-layout: fixed,确保列宽严格按照设定值渲染。
  3. 清理冗余代码:删除空行、空<tr>,修复未闭合内容,简化内部嵌套标签。

修正后的完整代码

<table align="center" border="1" cellpadding="1" cellspacing="1" style="background-color:#ebf5f7; width:1200px; table-layout: fixed">
  <tbody>
    <tr>
      <td style="width:300px"><span style="font-family:Courier New,Courier,monospace"><strong>Attribute Name</strong></span></td>
      <td style="width:500px"><span style="font-family:Courier New,Courier,monospace"><strong>Attribute Type (or DXL if DXL Attribute)</strong></span></td>
      <td style="width:200px"><span style="font-family:Courier New,Courier,monospace"><strong>Enumerations</strong></span></td>
      <td style="width:300px"><span style="font-family:Courier New,Courier,monospace"><strong>Access (Value)</strong></span></td>
    </tr>
    <tr>
      <td style="width:300px"><span style="font-family:Courier New,Courier,monospace">[ACCEPTANCE CATEGORY]</span></td>
      <td style="width:500px"><span style="font-family:Courier New,Courier,monospace">Text</span></td>
      <td style="width:200px">&nbsp;</td>
      <td style="width:300px">&nbsp;</td>
    </tr>
    <tr>
      <td style="width:300px"><span style="font-family:Courier New,Courier,monospace">[ACCEPTANCE CRITERIA]</span></td>
      <td style="width:500px"><span style="font-family:Courier New,Courier,monospace">Text</span></td>
      <td style="width:200px">&nbsp;</td>
      <td style="width:300px"><span style="font-family:Courier New,Courier,monospace">Requirements Management<span style="color:#3278b2"> RMCD</span></span></td>
    </tr>
    <tr>
      <td style="width:300px">&nbsp;</td>
      <td style="width:500px">&nbsp;</td>
      <td style="width:200px">&nbsp;</td>
      <td style="width:300px"><span style="font-family:Courier New,Courier,monospace">Requirements Management<span style="color:#3278b2"> RMCD</span></span></td>
    </tr>
    <tr>
      <td style="width:300px"><span style="font-family:Courier New,Courier,monospace">[CAS 1 REVIEW]</span></td>
      <td style="width:500px"><span style="font-family:Courier New,Courier,monospace"><span style="color:#9966ff">[LIST]</span></span></td>
      <td style="width:200px"><span style="font-family:Courier New,Courier,monospace"><span style="color:#9966ff">[Batch 1]<br>[Batch 2]<br>[Batch 3]<br>[Legacy Process]</span></span></td>
      <td style="width:300px"><span style="font-family:Courier New,Courier,monospace">DOORS Admin<span style="color:#3278b2"> RMCDA</span><br>Requirements Management<span style="color:#3278b2"> RMCD</span></span></td>
    </tr>
    <tr>
      <td style="width:300px"><span style="font-family:Courier New,Courier,monospace">[Cop]</span></td>
      <td style="width:500px">&nbsp;</td>
      <td style="width:200px">&nbsp;</td>
      <td style="width:300px">&nbsp;</td>
    </tr>
    <tr>
      <td style="width:300px"><span style="font-family:Courier New,Courier,monospace">[DEVIATION JUSTIFICATION]</span></td>
      <td style="width:500px"><span style="font-family:Courier New,Courier,monospace">Text</span></td>
      <td style="width:200px">&nbsp;</td>
      <td style="width:300px"><span style="font-family:Courier New,Courier,monospace">DOORS Admin<span style="color:#3278b2"> RMCDA</span><br>Requirements Management<span style="color:#3278b2"> RMCD</span></span></td>
    </tr>
    <tr>
      <td style="width:300px"><span style="font-family:Courier New,Courier,monospace">[E-T ID]</span></td>
      <td style="width:500px"><span style="font-family:Courier New,Courier,monospace">Text</span></td>
      <td style="width:200px">&nbsp;</td>
      <td style="width:300px"><span style="font-family:Courier New,Courier,monospace">DOORS Admin<span style="color:#3278b2"> RMCDA</span><br>Requirements Management<span style="color:#3278b2"> RMCD</span></span></td>
    </tr>
    <tr>
      <td style="width:300px"><span style="font-family:Courier New,Courier,monospace">[FI]</span></td>
      <td style="width:500px">&nbsp;</td>
      <td style="width:200px">&nbsp;</td>
      <td style="width:300px">&nbsp;</td>
    </tr>
  </tbody>
</table>

内容的提问来源于stack exchange,提问作者Ammo999

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.13 20:07:31