<html> <head> <title>网页怎么居中</title> <style type="text/css"> #all { position:absolute; width:100%; height:768px; z-index:1; left: 0px; top: 0px; } #all #main { background-color: #CCC; height: 768px; width: 1024px; margin-right: auto; margin-left: auto; } </style> </head> <body> <div id="all"> <div id="main"></div> </div> </body> </html>