DIV+CSS自适应宽度:
<!DOCTYPE html/>
<html>
<head>
<title>自适应宽度实例--www.ops.cc</title>
<style type="text/css">
/* 自适应宽度 */
#left{width:150px;margin-right:-150px;float:left;}
#center{width:auto;margin:0 0 0 150px;}
#right{width:140px;margin-left:-140px;float:right;}
/* 自适应高度度 */
/* warp 用于隐藏溢出的部分 */
#wrap{overflow:hidden;}
#left,#center,#right{padding-bottom:20000px;margin-bottom:-20000px;}
</style>
</head>
<body>
<div >
<div >左边栏,固定宽度150px;高度600px</div>
<div >右边栏,固定宽度150px;高度:自适应</div>
<div >中间栏,宽度:自适应,高度:自适应</div>
</div>
</body>
</html>
1. 注意适应宽度时候是将左栏和右栏先排列好后让中间栏自由排列,所以<div />的顺序
2. 自动高度将重写div的margin-bottom属性,当同时自动宽度和自动高度时。最好自动高度样式应在自动宽度之后。
#sidebar { width:auto; float:left;margin:0 762px 0 0;}
#main{width:742px;float:right;margin-left:-762px}
文章原创转载请注明出处:http://newmin.cnblogs.com/archive/2010/11/04/div-css-auto-width-and-height.html