随着主要内容的div内容增多.左右2边高度也增高..
<!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=gb2312" />
<title>无标题文档</title>
<style type="text/css">
/* css Reset */
html,body,div,span,p,h1,h2,h3,h4,h5,h6,img,ol,ul,li,form,input,dl,dt,dd,table,tr,td,em,strong{
margin:0;
padding:0;
}
ul,ol{
list-style:none outside none;
}
img{
border:none;
}
h1,h2,h3,h4,h5,h6{
font-size:100%;
}
.clear{clear:both}
/* Reset End */
.box1{width:827px;}
.left{border:1px solid orange;width:200px;float:left;}
.main{border:1px solid blue;width:400px;float:left;margin-left:10px;}
.right{border:1px solid green;float:right;margin-left:10px;width:200px;}
</style>
</head><body>
<div class="box1">
<div class="left">左边内容</div>
<div class="main">主要内容</div>
<div class="right">右边内容</div>
</div>
</body>
</html>

解决方案 »

  1.   


    <!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=gb2312" />
    <title>无标题文档</title>
    <style type="text/css">
    /* css Reset */
    html,body,div,span,p,h1,h2,h3,h4,h5,h6,img,ol,ul,li,form,input,dl,dt,dd,table,tr,td,em,strong{
    margin:0;
    padding:0;
    }
    ul,ol{
    list-style:none outside none;
    }
    img{
    border:none;
    }
    h1,h2,h3,h4,h5,h6{
    font-size:100%;
    }
    .clear{clear:both}
    /* Reset End */
    .box1{width:827px;}
    .left{border:1px solid orange;width:200px;float:left;}
    .main{border:1px solid blue;width:400px;float:left;margin-left:10px;}
    .right{border:1px solid green;float:right;margin-left:10px;width:200px;}
    </style>
    </head><script type="text/javascript">
        window.onload = function() {
            var main_height = document.getElementById('main').offsetHeight;
            var left_height = document.getElementById('left').offsetHeight;
            var right_height = document.getElementById('right').offsetHeight;        if (left_height < main_height) {
                document.getElementById('left').style.height = main_height+"px";
            }
            if (right_height < main_height) {
                document.getElementById('right').style.height = main_height+"px";
            }    }
    </script><body>
    <div class="box1">
    <div class="left" id="left">左边内容</div>
    <div class="main" id="main">主要内容<br />Test<br />ABC</div>
    <div class="right" id="right">右边内容</div>
    </div>
    </body>
    </html>