代码拷贝至HTML文档运行观看:
<!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"> <!-- #allbody{width:641px;margin:0px auto;overflow:hidden; text-align:center} #left{width:160px;float:left;clear:both;background:#F2F9FF;padding-bottom:100000px;margin-bottom:-100000px;} #right{width:463px;margin-left:18px;float:right;background:#bfbfbf} --> </style> </head>
<body> <div id="allbody"> <div id="left"> <p> </p> <p> </p> <p> </p> <p> </p> left内容 <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> </div> <div id="right"> <p> </p> <p> </p> <p> </p> <p> </p> right内容 <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> <p> </p> </div> </div>
</body> </html>
定义主体allbody的overflow:hidden;
主题内分为left、right两部分
定义left的padding-bottom:100000px;margin-bottom:-100000px;
这样right部分的高度就会总跟随left的高度了
当DIV有了宽度和position:relative |