Flexbox 垂直居中

2018-01-02 13:05:00
admin
原创
558
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Flexbox 垂直居中</title>
	
	<style>
	.Aligner {
  display: flex;
  align-items: center;
  min-height: 24em;
  justify-content: center;
}

.Aligner-item {
  flex: 1;
}

.Aligner-item--top {
  align-self: flex-start;
}

.Aligner-item--bottom {
  align-self: flex-end;
}

.Aligner-item--fixed {
  flex: none;
  max-width: 50%;
}
	</style>
</head>
<body>
	<div class="Aligner">
  <div class="Aligner-item Aligner-item--top">顶</div>
  <div class="Aligner-item">中</div>
  <div class="Aligner-item Aligner-item--bottom">底</div>
</div>
</body>
</html>
  • QQ讨论群
  • 关注微信
    • 欢迎咨询
    • 欢迎加入QQ群 16506021
  • 公众号:源宝网络