日期:2014-05-17 浏览次数:20851 次
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<style type="text/css">
html, body
{
height: 100%;
margin: 0px;
}
</style>
</head>
<body>
<table style="width: 100%; height: 100%" cellpadding="0" cellspacing="0">
<tr style="height: 100px;">
<td style="background-color: gray">
menu
</td>
</tr>
<tr style="height: 100%;">
<td style="background-color: yellow;">
</td>
</tr>
</table>
</body>
</html>
------解决方案--------------------
js
设置
<div id="x" style="height: 100%; background-color: yellow; overflow: scroll">
content</div>
<script>
window.onload = function () {
document.getElementById("x").style.height = document.getElementById("x").parentNode.offsetHeight + "px"
}
</script>
------解决方案--------------------
下面的代码在IE8和Firefox下测试通过
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>无标题文档</title>
<style type="text/css">
html, body
{
margin:0;padding:0;height:100%;
}
</style>
</head>
<body>
<div style="background:red;height:100%; position: relative;">
<div style="background:gray;height:100px">header</div>
<div style="background:orange;position: absolute; top: 100px;bottom:0;width:780px;overflow:scroll">
内容开始,设置width:780px;为了区分滚动条是div的不是整个窗口的。你可以设置成width:100%
<p>Bottom</p><p>Botto