三栏的网页布局,中间内容不确定高,问怎么让两边的背景始终与内容高度一致,说了两种
<!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 http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style type="text/css">
#box{ width:1000px;}
#left{ width:300px; background:#699; float:left}
#center{ width:600px;background:#FC3; padding:10px; border:20px solid #f00; float:left}
</style>
</head>
<body>
<div id="box">
<div id="left">111</div>
<div id="center">
ccccccccccccc
<br />
ccccccccccccc
<br />
ccccccccccccc
<br />
ccccccccccccc
<br />
ccccccccccccc
<br />
ccccccccccccc
<br />
ccccccccccccc
<br />
ccccccccccccc
<br />
ccccccccccccc
<br />
</div>
</div>
</body>
<script type="text/javascript">
window.onload=function(){
document.getElementById("left").style.height= document.getElementById("center").offsetHeight+'px';
}
</script>
</html>
这自问自答,呵呵