使用flex布局(多行,一行三个),换行后最后一行左右对齐问题


 

<html>

<head>
  <style>
    html,
    body,
    ul {
      margin: 0;
      padding: 0;
    }

    ul {
      width: 100%;
      display: flex;
      flex-wrap: wrap;
      /* justify-content: space-between; */
    }

    li {
      width: 33%;
      background: #ededee;
      margin-top: 1rem;
      list-style: none;
    }

    ul:after {
      content: "";
      width: 30%;
      height: 0px;
      visibility: hidden;
    }
  </style>
</head>

<body>
  <ul>
    <li>1</li>
    <li>1</li>
    <li>1</li>
    <li>1</li>
    <li>1</li>
    <li>1</li>
    <li>1</li>
    <li>1</li>
    <li>1</li>
    <li>1</li>
    <li>1</li>
  </ul>
</body>

</html>

 

主要代码:

父:

 ul {
      width: 100%;
      display: flex;
      flex-wrap: wrap;
      justify-content: space-between;
  }

 

子:

li {
      width: 33%;
}

 

 

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM