HTML table:colgroup 与固定列宽
要点:
- 使用
tableLayout: fixed+colgroup/col定义列宽以固定布局;否则列宽定义可能不生效。 col仅定义列宽,无法控制文本溢出;需对单元格本身设置省略或换行策略。
示例
<table style={{ tableLayout: 'fixed', width: '100%' }}>
<colgroup>
<col style={{ width: '100px' }} />
<col style={{ width: '100px' }} />
<col style={{ width: '100px' }} />
</colgroup>
{/* ... */}
</table>