<div class="htmlarea"><textarea id="runcode1116"> <title></title> <style type="text/css"> body { font:12px Tahoma;margin:0px;text-align:center; } a:link,a:visited {font-size:12px;text-decoration:none;} a:hover{} /*页面层容器*/ #container { width:780px;margin:0px auto;background:#fff } /*页面头部*/ #header {background:url(logo.gif) no-repeat;} #banner { background:url(banner.jpg) 0px no-repeat; /*加入背景图片*/;background:#999; width:780px; /*设定层的宽度*/ margin:auto; /*层居中*/ height:200px; /*设定高度*/ border-bottom:5px solid #EFEFEF; /*画一条浅灰色实线*/ clear:both /*清除浮动*/ } #pagebody { width:780px; /*设定宽度*/ margin:0px auto; /*居中*/ background:#000 } #sidebar { width:200px; /*设定宽度*/ text-align:left; /*文字左对齐*/ float:left; /*浮动居左*/ background:#f3c;color:#666 overflow:hidden; /*超出宽度部分隐藏*/ height:300px; padding:0px } #mainbody { width:580px; text-align:left; margin:0px auto; /*居中*/ float:right; overflow:hidden; color:#fff } /*页面底部*/ #footer{ width:780px;margin:0 auto;height:65px;background:#999;repeat-x;color:#ff0066;clear:both; } </style> <div id="container"></div> <div id="header"> <div id="banner"></div> </div> <div id="pagebody"> <div id="sidebar"><h2>这一层需要与右边的层同步,也需要自适应高度</h2></div> <div id="mainbody"><h2>想使这一层自动适应高度,有办法吗?</h2></div> <div style="clear:both;height:1px;margin-bottom:-1px;padding:0; background:#FF0000"></div> </div> <div id="footer">这一层不变</div></textarea></div> <br><input onclick="runEx('runcode1116')" type="button" value="运行代码"> <input onclick="doCopy('runcode1116')" type="button" value="复制代码"> <input onclick="doSave(runcode1116)" type="button" value="保存代码">[Ctrl+A 全选 注:<a href="/article/23421.htm" title="查看具体详情" target="_blank">如需引入外部Js需刷新才能执行</a>]