0

如何在 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>
4

1 回答 1

2

您还需要使用display: table-cell;vertical-align: middle;属性text-align: center;来将文本垂直和水平居中对齐

演示

div {
    border: 1px solid #f00;
    display: table-cell;
    text-align: center;
    vertical-align: middle
}
于 2013-05-29T04:41:52.450 回答