p{
width:150px;line-height:50px;
background:#58a;
color:white;
text-align:center;
}
<body>
<p>hello world</p>
</body>
給p
設置line-height
,使得p
中的文本hello world
能夠垂直居中;
text-align:center
,使得p
中的文本hello world
能夠水平居中。