flex布局space-between最后一行如何左对齐

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    .content {
      width: 1000px;
      background-color: #999;
      display: flex;
      justify-content: space-between;
      flex-wrap: wrap;
    }

    .content .box {
      width: 210px;
      height: 100px;
      margin: 10px 20px; /* margin 需要计算*/
      background-color: aqua;
    }
    /* 1.外层元素加伪类设置flex:auto */
    /* .content::after{
      content: '';
      flex: auto;
    } */
  </style>
</head>

<body>
  <div class="content">
    <div class="box"></div>
    <div class="box"></div>
    <div class="box"></div>
    <div class="box"></div>
    <div class="box"></div>
    <div class="box"></div>

    <!-- 2.一行需要几个元素就写n-2个下面的标签-->
    <div class="box" style="visibility: hidden;height: 0"></div>
    <div class="box" style="visibility: hidden;height: 0"></div>
  </div>

</body>

</html>
posted @ 2021-12-30 16:35  Samsara315  阅读(63)  评论(0编辑  收藏  举报