答案 0 :(得分:1)
查看jsfiddle
中的解决方案详细
Html代码
<div>
<p>text+<br>sdffd</p>
</div>
<br/><br/>
<a href="#" class="switchFont">Switch Font</a>
CSS
div{
width: 200px;
height: 200px;
border: 1px solid black;
display: table; //added
}
p{
line-height: 20px; //changed
font-size: 18px;
text-align: center;
display: table-cell; //added
vertical-align: middle; //added
}
p.times{
font-family: "verdana"; //changed
}
答案 1 :(得分:0)
您可以通过将此CSS放在div上来垂直对齐中间文本:
text-align: center;
display: table-cell;
vertical-align: middle;