Flexbox - 垂直居中文本

Skr*_*dde 10 html css css3 centering flexbox

我有一个方形的flexbox,完全覆盖了一个超链接.

现在我想垂直居中flexbox的内容.

然而,使用div与属性元素display: table和嵌套div与物业display: table-cell; vertical-align: middle不工作,因为我失去了方形.

如果我使用divs代替ul而且li我失去了能够随处点击的属性.

我希望"文本"在红色框的水平和垂直中心对齐:

body {
  margin: 0px;
  width: 100%;
}
main {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
}
.flex-container {
  width: 100%;
}
ul {
  display: flex;
  flex-wrap: wrap;
  list-style: none;
  -webkit-padding-start: 0px;
  -webkit-margin-before: 0px;
  -webkit-margin-after: 0px;
}
li {
  display: flex;
  flex-direction: column;
  width: 50%;
}
.red {
  background-color: red;
}
.white {
  background-color: white;
}
.tile:before {
  content: '';
  float: left;
  padding-top: 100%;
}
.tile {
  text-align: center;
}
Run Code Online (Sandbox Code Playgroud)
<main>
  <div class="flex-container">
    <ul>
      <li class="red">
        <a href="/">
          <div class="tile">
            Text
          </div>
        </a>
      </li>
    </ul>
  </div>
</main>
Run Code Online (Sandbox Code Playgroud)

Mic*_*l_B 17

main {
  height: 200px;
  width: 200px;
}
a {
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: red;
  height: 100%;
}
Run Code Online (Sandbox Code Playgroud)
<main>
  <a href="/">
    <div class="tile">Text</div>
  </a>
</main>
Run Code Online (Sandbox Code Playgroud)