表格应该有实际宽度
我有一个表格:
<table border="1px">
<tr>
<td style="width:200px">td1</td>
<td style="width:3200px">td2</td>
</tr>
</table>
浏览器将其适合当前窗口,我认为它的宽度比例。 我希望表格具有实际宽度,以便窗口在必要时滚动。
I have a table:
<table border="1px">
<tr>
<td style="width:200px">td1</td>
<td style="width:3200px">td2</td>
</tr>
</table>
and the browser fits it in the current window, in it's width proportions I think.
I would like the table to have it's real width, so that the window scrolls if necessary.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不知道为什么表格会这样 - 我对任何能够深入解释为什么 td 上的宽度被覆盖的人表示支持。
最简单的方法是为
table
元素指定复合宽度:或者,将 3200px 宽的元素放入
td
中似乎也可以:I don't know why the table behaves this way - upvotes from me for anybody who can explain in depth why the width on the
td
s gets overridden.The easiest way around it would be giving the
table
element the composite width:alternatively, putting a 3200px wide element into the
td
seems to work as well:当表格不再溢出时,TD 宽度始终被解释为相对于整个表格宽度的百分比。除非设置了明确的宽度,否则表格不会溢出水平边缘。
TD widths are always interpreted as percentages in relation to the width of the entire table when the table does not overflow anymore. Tables do not overflow past the horizontal edge unless they have an explicit width set.