目标效果
    image.png
    实现方法: 1. text-align: “center” 2. line-height=容器高度

    1. <!DOCTYPE html>
    2. <html lang="en">
    3. <head>
    4. <meta charset="utf-8">
    5. <link rel="stylesheet" href="../css/index.css" type="text/css">
    6. </head>
    7. <body>
    8. <p>请让这行文本水平垂直居中显示</p>
    9. </body>
    10. </html>
    p{
        width: 250px;
        height: 100px;
        border: 1px solid black;
        text-align: center;/*水平居中*/
        line-height: 100px;/*让文字的行高和容器的高度一样*/
    }