---
title: "DIV居中"
author: "bocent"
date: "2009-08-13T16:38:14Z"
tags: []
slug: "div"
draft: false
lastmod: "2009-08-13T17:27:36Z"
id: 446436
url: "https://bocent.iteye.com/blog/446436"
---

要设置div居中,光设置align=center是不行的必须设置margin-right:auto; margin-left:auto;

```
<body  style="border: 0;margin: 0px;" >
<div style="width:945px;height:100%;border:0px;margin-right:auto; margin-left:auto;" align="center">
<div class="MainMenu" style="width:945px;vertical-align:middle;">
</div>
</body>
```