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