<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title></title>
    <style>
        body{
            margin: 0px auto;
        }
        .app {
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            width: 100vw;
            height: 100vh;
            font-size: 8rem;
            background: hsl(240, 100%, 67%);
            color: hsl(0, 0%, 100%);
        }
    </style>
</head>

<body>
    <div class="app">
        <h3>Hey</h3>
    </div>
</body>

</html>

用flex将内容居中

用flex将内容居中

 

支持将任意的元素标签<p>、<h2>、<img>居中显示

flex-direction: column;

justify-content: center;

align-items: center;

//这三个样式标签自己体验下就知道有什么作用

 

相关文章:

  • 2022-02-04
  • 2021-07-01
  • 2021-08-31
  • 2022-01-01
  • 2022-01-01
  • 2021-07-16
  • 2021-11-17
  • 2021-05-28
猜你喜欢
  • 2022-12-23
  • 2021-09-27
  • 2021-09-08
  • 2021-12-20
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案