CSS 水平垂直居中:flex+justifycontent+algin-items

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>水平垂直居中:flex+justifycontent+algin-items</title>
		<style type="text/css">
			*{
				margin: 0;
				padding: 0;
			}
			html,body{
				height: 100%;
				width:100%;
			}
			.parent{
				display: flex;
				height: 100%;
				width: 100%;
				justify-content: center;
				align-items: center;
				background-color: aqua;
			}
			.son{
				background-color: red;
			}
		</style>
	</head>
	<body>
		<div class="parent">
			<div class="son">
				使用弹性盒模型
			</div>
		</div>
	</body>
</html>

猜你喜欢

转载自blog.csdn.net/xvzhengyang/article/details/84593260