Flexbox垂直居中

2018-01-03 10:34:00
admin
原创
539
<!DOCTYPE html>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>Flexbox垂直居中Demo</title>
	</head>
<style>
#container{
	height:300px;
	background:#d6d6d6;
	display:flex;
	justify-content:center;
  align-items: center;
}

#center{
	width:100px;
	height:100px;
	background-color:#666;
	color:#fff;
	font-weight:bold;
	font-size:18px;
	
	display:flex;		/*这个写在这只是为了#center这几个字的垂直居中*/
	justify-content:center;
  align-items: center;
}
</style>
	<body>
	<div id='container'>
		<div id = 'center'>#center</div>
	</div>
		
	</body>
</html>
  • QQ讨论群
  • 关注微信
    • 欢迎咨询
    • 欢迎加入QQ群 16506021
  • 公众号:源宝网络