css - IE8 忽略 td 宽度,适用于 IE7

标签 css internet-explorer-8 html-table width

有一张表是这样的:

<table width="100%">
<tr id="header">
 <td colspan="2"></td>
</tr>
<tr id="center">
 <td id="left" style="width: 201px"></td>
 <td id="mainpage" style="width: 100%"></td>
</tr>
</table>

在除 IE8 之外的所有浏览器(包括 IE7)中,“左”td 都可以。在 IE8 中它超过了主页内容的宽度。

我会发布一些屏幕截图,但这是我在这里发布的第一篇文章。

有什么想法吗?

最佳答案

第二列的 width: 100% 看起来不对 - 如果您想让第二列扩展到可用空间的其余部分,则不需要根本没有,所以你可以删除它。 另外,将此添加到您的表中:

table-layout: fixed;

确保遵守宽度。

完整代码:

<table style="width: 100%; table-layout: fixed;">
<colgroup>
    <col style="width: 201px">
</colgroup>
<tr id="header">
    <td colspan="2"></td>
</tr>
<tr id="center">
    <td id="left"></td>
    <td id="mainpage"></td>
</tr>
</table>

关于css - IE8 忽略 td 宽度,适用于 IE7,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3306861/

相关文章:

html - 从模型 AngularJS 创建表

css - 无法在 outlook 中设置单元格间距 - html 电子邮件

javascript - 从 rowid 获取表格单元格 id

html - 我如何建议水平规则作为好的分页点?

IE8 及以下版本宽度属性的 CSS hack

html - 纯 CSS HTML 表格单元格在单击时展开/折叠

css - 两个 body 背景图像在 IE8 中消失

javascript - iframe.contentDocument 不适用于 IE8

css - Scriptaculous Effect.Appear glitch onmouseover

javascript - div 内的 jQuery 可放置中心图像