<div class="container">
<div class="vert">
<h1>Hi, I'm Nested &<span>Vertically Aligned</span></h1>
<p>Abigo sudo mara paulatim odio, accumsan luptatum nibh nibh refero metuo opes ut fatua. Acsi et fere similis <strong>Using</strong> augue <strong>absolute</strong> validus. Regula <strong>positioning</strong> eu jus vel, indoles fere iaceo ea similis. Velit praemitto nulla vel luctus secundum. </p>
</div>
</div>
这时候,就必须在定义父级元素的CSS代码中加入position: relative;才能够使内部元素垂直居中于父级内部,代码如下:
.container {
position: relative;
height: 500px;
width: 800px;
border: 10px solid #999;
background: #000;
margin: 20px;
}