代码示例:(标识:css3_align_flex)
<!DOCTYPE html>
<html>
<head>
<style>
.center {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 200px;
  border: 3px solid green; 
}
</style>
</head>
<body>

<h1>弹性框</h1>

<p>同时将 justify-content 和 align-items 属性设置为 <em>center</em> 的容器将使项目在中心(在两个轴上)对齐。</p>

<div class="center">
  <p>我同时在水平和垂直方向对齐。</p>
</div>

</body>
</html>
运行结果: