代码:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>div居中</title>
  <style>
       * {
            margin:0;
            padding:0;
          }
          .content {
            width:400px;
            height:400px;
            background:orange;
            border: 1px solid green;
            position:relative;
            margin: 100px auto;
          }
          .nav {
            width:80px;
            height:80px;
            line-height:80px;
            text-align:center;
            background:green;
            margin: auto;
            position:absolute;
            left: 0;
            top: 0;
            bottom:0;
            right: 0;
          }
  </style>
</head>
<body>
  <div class="content">
         <div class="nav">这是内容</div>
    </div>
</body>
</html>

  效果:

小div在大div中垂直居中方式

 

相关文章:

  • 2022-12-23
  • 2022-01-09
  • 2021-05-17
  • 2022-12-23
猜你喜欢
  • 2021-11-21
  • 2022-12-23
  • 2021-10-26
  • 2021-11-13
  • 2021-12-13
相关资源
相似解决方案