如何将div中的文本内容与水平居中和垂直居中对齐?
<div style="height: 300px;">
<p>Envision various details for your big day with help from our photo catalog, which features images filtered by category. See actual works from suppliers to help you make decisions.</p>
</div>
答案 0 :(得分:2)
您需要将display: table-cell;
和vertical-align: middle;
属性与text-align: center;
一起使用,以使文本垂直和水平居中对齐
div {
border: 1px solid #f00;
display: table-cell;
text-align: center;
vertical-align: middle
}