flex实现流式布局


摘自阮老师的博客 点击查看运行效果

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
  <style>
      * {
        margin: 0;
        padding: 0;
       }
      .parent {
        width: 200px;
        height: 150px;
        background-color: black;
        display: flex;
        flex-flow: row wrap;
        align-content: flex-start;
      }

      .child {
        box-sizing: border-box;
        background-color: white;
        flex: 0 0 25%;
        height: 50px;
        border: 1px dotted grey; 
        list-style: none;
      }
  </style>
</head>
<body>
  <ul class="parent">
    <li class="child"></li>
    <li class="child"></li>
    <li class="child"></li>
    <li class="child"></li>
    <li class="child"></li>
    <li class="child"></li>
    <li class="child"></li>
    <li class="child"></li>
    <li class="child"></li>
    <li class="child"></li>
    <li class="child"></li>
    <li class="child"></li>
  </ul>
</body>
</html>


免责声明!

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



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