<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    <title>CSS | 元素居中</title>
    <style>
      body {
        margin: 0 auto;
        align-content: center;
      }
      .parent {
        width: 480px;
        height: 480px;
        background-color: lightgray;
        display: flex;
        align-items: center;
        justify-content: center;
      }

      .child {
        width: 400px;
        height: 400px;
        background-color: lightblue;
      }
    </style>
  </head>
  <body>
    <div class="parent">
      <div class="child"></div>
    </div>
  </body>
</html>

CSS | 元素居中

相关文章:

  • 2021-09-20
  • 2021-12-09
  • 2021-05-28
  • 2021-07-17
  • 2021-06-09
  • 2021-11-01
  • 2022-12-23
猜你喜欢
  • 2021-07-09
  • 2021-12-09
  • 2021-12-23
  • 2022-02-08
  • 2022-01-15
  • 2021-07-14
  • 2022-02-22
相关资源
相似解决方案