Application off from the parent phase to achieve vertical centering

		.box {
		/*width:占有宽度*/
	    width: 100%;
	    height: 200px;
		background: #eee;
		/*利用padding挤出1,3位置*/
		padding: 0 200px;
		/*内减盒模型*/
		box-sizing: border-box;
		position: relative;
	}
	.box p:first-child {
		/*绝对定位*/
		position: absolute;
		width: 200px;
		height: 200px;
		background-color: green;
		left: 0;
	}
	.box p:last-child {
		/*绝对定位*/
		position: absolute;
		width: 200px;
		height: 200px;
		background-color: green;
		right: 0;
		top: 0;
	}
	.box p:nth-child(2) {
		/*标准流  父盒子内容宽的比值*/
		width: 100%;
		height: 200px;
		background-color: orange;
		}

</style>
<body>
	<div class="box">
		<P></P>
		<P></P>
		<P></P>
	</div>

 

Guess you like

Origin blog.csdn.net/qq_41328247/article/details/88725722