<div id="demo">
<p>测试</p>
</div>
<style>
#demo{
width: 200px;
background: red;
height: 200px;
float: left;
/*flex 布局*/
display: flex;
/*实现垂直居中*/
align-items: center;
/*实现水平居中*/
justify-content: center;
text-align: justify;
margin:0 auto;
color:#fff;
}
</style>