<!DOCTYPE?HTML>
<html>
<head>
<meta?http-equiv="Content-Type"?content="text/html;?charset=utf-8">
<title>定寬塊狀元素水平居中</title>
<style>
.p1{background-color:#09C;height:500px;vertical-align:middle;}
.p2{
display:inline-block;
background-color:#666;
}
</style>
</head>
<body>
<div?class="p1">
??<div?class="p2"><span>垂直居中垂直居中垂直居中垂直居中垂直居中?</span></div>
</div>
</body>
</html>
2 回答

Yexiaomo
TA貢獻152條經驗 獲得超157個贊
文字垂直居中, 把放置文字容器的 height 和 line-height 設成一樣就行了
height:25px;??? line-height:25px;
像你上面的,這樣就行了
.p2{ ????display:inline-block; ????background-color:#666; ????height:?500px; ????line-height:?500px; }
- 2 回答
- 0 關注
- 1454 瀏覽
相關問題推薦
添加回答
舉報
0/150
提交
取消