请注意以下简单的 jsFiddle - http://jsfiddle.net/mark69_fnd/DaYCa/28/
HTML:
<html>
<head>
<link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/3.7.3/build/cssreset/reset-min.css">
</head>
<body>
<div class="container table">
<div class='thead'>
<div class='tr'>
<div class='td'>
<div class='header'>header</div>
</div>
</div>
</div>
<div class='tbody'>
<div class='tr'>
<div class='td'>
<div class='content'>content</div>
</div>
</div>
</div>
<div class='tfoot'>
<div class='tr'>
<div class='td'>
<div class='footer'>footer</div>
</div>
</div>
</div>
</div>
</body>
</html>
CSS:
html, body {
height: 100%;
width: 100%;
font-family: sans-serif;
}
.container {
height: 100%;
width: 100%;
background-color: #ddd;
display: table;
}
.thead {
display: table-header-group;
}
.tbody {
display: table-row-group;
}
.tfoot {
display: table-footer-group;
}
.tr {
display: table-row;
}
.td {
display: table-cell;
}
.content {
background-color: #bbb;
border: solid 1px;
height: 100%;
}
.header {
background-color: #999;
border: solid 1px red;
}
.footer {
background-color: #999;
border: solid 1px green;
}
铬合金:
火狐和 IE9:
如何更改代码,使其在所有三种浏览器上看起来都与 Chrome 相同?
PS 固定高度可用于页眉和页脚,但不能用于内容。