<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>文字垂直居中</title>
<style type="text/css">
.content-box{
width: 800px;
height: 500px;
margin:0 auto;
border: 1px solid #dedede;
text-align: center;
/*display: table;*/
}
.p-box{
/*display: table-cell;
vertical-align: middle;*/
display: inline-block;
}
.theI{
height: 100%;
vertical-align: middle;
width: 0;
display: inline-block;
}
</style>
</head>
<body>
<div class="content-box">
<div class="p-box">
<p>这是居中的文字P1</p>
<p>这是居中文字P2</p>
</div>
<i class="theI"></i>
</div>
</body>
</html>
CSS文字垂直居中实例
最新推荐文章于 2023-09-30 13:11:25 发布