grid佈局 flex彈性佈局 (九宮格)

https://www.jianshu.com/p/d183265a8dad 網格佈局html

http://www.zuojj.com/archives/279.html 彈性佈局佈局

彈性佈局九宮格flex

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

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <style>
    .box {
      width: 300px;
      height: 300px;
      background: silver;
      margin: 80px auto;
      display: flex;
      flex-direction: column;
      flex-wrap: nowrap;
      justify-content: space-between;
      align-items: center;
    }

    .top,
    .middle,
    .bottom {
      width: 100%;
      display: flex;
      flex-direction: row;
      flex-wrap: nowrap;
      justify-content: space-between;
      align-items: center;
    }
  </style>
</head>

<body>
  <div class="box">
    <div class="top">
      <div class="left">1</div>
      <div class="center">2</div>
      <div class="right">3</div>
    </div>
    <div class="middle">
      <div class="left">4</div>
      <div class="center">5</div>
      <div class="right">6</div>
    </div>
    <div class="bottom">
      <div class="left">7</div>
      <div class="center">8</div>
      <div class="right">9</div>
    </div>
  </div>
</body>

</html>
相關文章
相關標籤/搜索