---
title: "CSS3 水平垂直居中"
author: "何不笑"
date: "2013-07-22T13:30:01Z"
tags: []
categories: ["Web前端"]
slug: "css3"
draft: false
lastmod: "2013-07-22T13:30:01Z"
id: 1911410
url: "https://wait7758521.iteye.com/blog/1911410"
---

```
Center the child elements of a div box by using the box-align and box-pack properties together:

div
{
width:350px;
height:100px;
border:1px solid black;

/* Internet Explorer 10 */
display:-ms-flexbox;
-ms-flex-pack:center;
-ms-flex-align:center;

/* Firefox */
display:-moz-box;
-moz-box-pack:center;
-moz-box-align:center;

/* Safari, Opera, and Chrome */
display:-webkit-box;
-webkit-box-pack:center;
-webkit-box-align:center;

/* W3C */
display:box;
box-pack:center;
box-align:center;
}
```

 From:[http://www.w3schools.com/cssref/css3\_pr\_box-pack.asp](http://www.w3schools.com/cssref/css3_pr_box-pack.asp)