如何水平居中和垂直居中对齐 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>
最佳答案
您需要使用 display: table-cell;
和 vertical-align: middle;
属性以及 text-align: center;
作为以及将文本垂直和水平居中对齐
div {
border: 1px solid #f00;
display: table-cell;
text-align: center;
vertical-align: middle
}
关于html - CSS:如何水平居中和垂直居中对齐文本内容?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16805606/