Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Webkit 检查器无法告诉我为什么我的表格单元格不遵守width样式。我可以让它们拉伸以适应整行(通过设置white-space: nowrap或拉伸以适应最长的单词,但我只希望单元格具有一定数量的像素宽。
width
white-space: nowrap
尝试添加table-layout: fixed;到表的 CSS 声明中。
table-layout: fixed;
首先,检查一下:
固定表格单元格宽度
现在,
对于固定单元格大小 ( <td>),请使用:
<td>
<col width="50px"/>
在你之前
<tr>
或者,使用:
<table width = 100>
或者
<table style="width:100px">
固定表大小。
在以下情况下,CSS 中“自动换行”属性的“中断词”值很有用:
word-wrap:break-word