<h6>文本的垂直居中</h6>
<div class="singleline">
<p>1.单行文本的垂直居中可以使用line-height</p>
</div>
<div class="multiline">
<b>2.多行文本的垂直居中使用上下padding</b>
</div>
.singleline{
height:6em;
border:1px solid #ccc;
width:40ch;
float:left;
}
.singleline p{
line-height:6em;
margin:0px;
}
.multiline{
border:1px solid #999;
width:20ch;
padding:2% 0;
float:left;
}
*{
background-color:#1D1F20;
color:#fff;
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.