flex--伸缩盒子布局---等分

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Flex demo 2</title>
  <style>
    .container {
      display: flex;
      flex-direction: column;/*改变主轴方向,column列从上往下,默认是row行从左往右*/
      width: 400px;
      height: 300px;
      border: 1px solid #ccc;
    }

    .item {
      flex: 1;
    }
    /* 总的是4份,每一项占一份 */
  </style>
</head>
<body>
  <div class="container">
    <div class="item" style="background-color: #0ff; width: 200px"></div>
    <div class="item" style="background-color: #ff0"></div>
    <div class="item" style="background-color: #f00"></div>
    <div class="item" style="background-color: #f0f"></div>
    <div class="item" style="background-color: #0ff"></div>
  </div>
</body>
</html>

  

posted @ 2019-09-20 21:38  小白咚  阅读(1456)  评论(0编辑  收藏  举报