div实现水平垂直居中

<div class="login-container">
    <div class="login-top-table">
      <div class="login-top-table-cell"> 
        <img src="../../../static/images/login-icon.png" class="login-top-img"/>
        <span class="login-title">页面标题</span>
      </div>
      
    </div>
  </div>

  

.login-container {
  background: url(../../../static/images/login-bg.png) no-repeat;
  background-size: 100% 100%;
  height: calc(100vh);
}

.login-top-table {
  height: calc(30vh);
  display: table;
  width: 100%;
}
.login-top-table-cell {
  display: table-cell;
  vertical-align: middle;
  text-align: center;
}

.login-top-img {
  width: 130px;
  display: inline-block;
  vertical-align: middle;
}
.login-title {
  color: #F54427;
    font-size: 50px;
    font-weight: bold;
    margin-left: 20px;
    display: inline-block;
    vertical-align: middle;
}

 

posted @ 2021-06-30 11:26  cmwang2017  阅读(45)  评论(0编辑  收藏  举报