我的页面有一个以页面为中心的主 div。我通过使用 margin: auto; 来做到这一点。
页面本身运行良好 - 但是一旦我包含一个从数据库动态加载数据的表,页面就无法正确对齐初始中心。
请看下面的例子:
<!DOCTYPE html>
<html>
<head>
<title>Invoice Control</title>
</head>
<body class="single">
<div id="wrapper" style="width:1100px;margin:auto;padding:10px; border: 1px solid gray">
<div id="content" style="border: 1px solid red">
here comes the table, which makes the site not center nicely
<table>
<tr>
<td>THIS IS DUMMY TEXT TO FILL THE TABLE AND EXCEED THE 1100PX</td>
<td>THIS IS DUMMY TEXT TO FILL THE TABLE AND EXCEED THE 1100PX</td>
<td>THIS IS DUMMY TEXT TO FILL THE TABLE AND EXCEED THE 1100PX</td>
<td>THIS IS DUMMY TEXT TO FILL THE TABLE AND EXCEED THE 1100PX</td>
<td>THIS IS DUMMY TEXT TO FILL THE TABLE AND EXCEED THE 1100PX</td>
<td>THIS IS DUMMY TEXT TO FILL THE TABLE AND EXCEED THE 1100PX</td>
<td>THIS IS DUMMY TEXT TO FILL THE TABLE AND EXCEED THE 1100PX</td>
<td>THIS IS DUMMY TEXT TO FILL THE TABLE AND EXCEED THE 1100PX</td>
<td>THIS IS DUMMY TEXT TO FILL THE TABLE AND EXCEED THE 1100PX</td>
<td>THIS IS DUMMY TEXT TO FILL THE TABLE AND EXCEED THE 1100PX</td>
<td>THIS IS DUMMY TEXT TO FILL THE TABLE AND EXCEED THE 1100PX</td>
<td>THIS IS DUMMY TEXT TO FILL THE TABLE AND EXCEED THE 1100PX</td>
<td>THIS IS DUMMY TEXT TO FILL THE TABLE AND EXCEED THE 1100PX</td>
<td>THIS IS DUMMY TEXT TO FILL THE TABLE AND EXCEED THE 1100PX</td>
<td>THIS IS DUMMY TEXT TO FILL THE TABLE AND EXCEED THE 1100PX</td>
<td>THIS IS DUMMY TEXT TO FILL THE TABLE AND EXCEED THE 1100PX</td>
<td>THIS IS DUMMY TEXT TO FILL THE TABLE AND EXCEED THE 1100PX</td>
<td>THIS IS DUMMY TEXT TO FILL THE TABLE AND EXCEED THE 1100PX</td>
<td>THIS IS DUMMY TEXT TO FILL THE TABLE AND EXCEED THE 1100PX</td>
<td>THIS IS DUMMY TEXT TO FILL THE TABLE AND EXCEED THE 1100PX</td>
<td>THIS IS DUMMY TEXT TO FILL THE TABLE AND EXCEED THE 1100PX</td>
<td>THIS IS DUMMY TEXT TO FILL THE TABLE AND EXCEED THE 1100PX</td>
<td>THIS IS DUMMY TEXT TO FILL THE TABLE AND EXCEED THE 1100PX</td>
</tr>
</table>
</div>
</div>
</body>
</html>
知道我必须做什么,以确保居中的 div 再次正确居中吗?