<!DOCTYPE html><html> <head> <Meta charset="UTF-8"> <title>上中下DIV+CSS布局案例</title> <style type="text/css"> #container{ background-color: darkgray; text-align: center; width: 800px; height: 600px; } #top{ background-color: antiquewhite; width: 780px; height: 100px; } #main{ background-color: #00FF00; width: 780px; height: 400px; } #bottom{ background-color: aqua; width: 780px; height: 100px; } </style> </head> <body> <!--需要兼容客户屏幕宽度,布局应该使用固定尺寸--> <!--p,h,div属于块状元素,前后会自动换行--> <!--div会自动占据整个父容器的宽度--> <center> <div id="container"> <center> <div id="top">TOP</div> <div id="main">MAIN</div> <div id="bottom">BottOM</div> </center> </div> </center> </body></html>