IE8中的无表格布局

时间:2014-08-30 17:44:14

标签: html css internet-explorer-8 header footer

是否可以在 IE8 中使用表格(仅使用CSS和div,不使用Javascript)复制完全此布局:

http://jsfiddle.net/u0u7snh6/2/

我尝试过多种情况, IE8 似乎要么搞乱了:

  • 内容单元格的高度
    • 高度不使用100%的可用空间
    • 高度使用超过100%并导致无法移除的溢出
  • 内容单元格的对齐

完全这个词在这里非常重要......除此布局之外的任何内容都不起作用, IE8 是强制性的。

否则,2014年使用表格进行布局是否很重要?

以下是简单的代码:

HTML

<body>
<table id="contentFrame">
    <tr style="background-color: pink;">
        <td>&nbsp;</td>
        <td id="contentCol">
            This is the header
        </td>
        <td>&nbsp;</td>
    </tr>
    <tr id="contentRow">
        <td></td>
        <td id="contentCell">
            This is the content
        </td>
        <td></td>
    </tr>
    <tr style="background-color: yellow;">
        <td></td>
        <td>
            This is the footer
        </td>
        <td></td>
    </tr>
</table>
</body>

CSS

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
}

#contentFrame {
    width: 100%;
    height: 100%;
    border-spacing: 0;
    border-collapse: collapse;
    empty-cells: show;
}

#contentRow {
    background-color: green;
}

#contentCell {
    height: 100%;
    vertical-align: middle;
    background-color: white;
}

#contentCol {
    width: 80%;
}

0 个答案:

没有答案