div+css自动扩展
在一个jsp页面中有一个div-a float:left(白色部分),一个div-b float:right(红色部分),div-a和div-b在一个div-c中,还有一个div-d(黑色部分)和div-c是并列的(如图)
白色的部分会自动增长,并且有一个初始高度,而黑色部分会随着他的增长,紧贴着他,这种效果怎么实现?
实现的代码越简单越好
div
css
jsp
------解决方案--------------------<!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" />
<style type="text/css">
body{margin:0px;padding:0px;color:black;text-align:center;font-family:Arial, Helvetica, sans-serif;font-size:12px;line-height: 140%;}
div{margin:0px;padding:0px;border:0px;}
#menu{background:#039; height:30px; width:800px}
.main{background:#CCC;}
.top{ background:#333; height:100px; width:800px; margin:0 auto}
#center{ background:#CCC;margin:0 auto; width:800px; overflow:auto}
#left{ background:#9F0;width:600px;float:left; margin:0 0}
#right{ background:#696;width:200px;float:right; margin:0 0}
.foot{background:#F0F; min-height:30px; width:800px; margin:0 auto}
</style>
<title>无标题文档</title>
</head>
<div class="main">
<div class="top"></div>
<div id="center" >
<div id="menu"></div>
<div id="left">
<p>1</p>
<p>1</p>
<p>1</p>
<p>1</p>
<p>1</p>
<p>1</p>
<p>1</p>
<p>1</p>
<p>1</p>
<p>1</p>
<p>1</p>
<p>1</p>
<p>1</p>
<p>1</p>
<p>1</p>
<p>1</p>
<p>1</p>
<p>1</p>
<p>1</p>
<p>1</p>
<p>1</p>
<p>1</p>
<p>1</p>
<p>1</p>
<p>1</p>
<p>1</p>
<p>1</p>
<p>1</p>
<p>1</p>
<p>1</p>
<p>1</p>
<p>1</p>
<p>1</p>
<p>1</p>
<p>1</p>
<p>1</p>
<p>1</p>
<p>1</p>
<p>1</p>
<p>1</p>
<p>1</p>
<p>1</p>
<p>1</p>
<p>1</p>
<p>1</p>
<p>1</p>
<p>1</p>
<td> 1</td>
</div>
<div id="right">
<p>1</p>
<p>1</p>
<p>1</p>
<p>1</p>
<p>1</p>
<p>1</p>
<p>1</p>
<p>1</p>
<p>1</p>
<p>1</p>
</div>
</div>
<div class="foot">
<p>底部</p>
</div>
<br style="clear:both;" />
</div>
<script type="text/javascript">
document.getElementById("right").style.height=document.getElementById("center").scrollHeight+"px";
document.getElementById("left").style.height=document.getElementById("center").