关于web布局

77 阅读1分钟

flex

<!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>
  </head>
  <style>
    * {
      margin: 0;
      padding: 0;
    }
    html,
    body {
      height: 100%;
    }
    #parent {
      display: flex;
      flex-direction: column;
      width: 100wh;
      height: 100vh;
    }
    #top {
      height: 100px;
      background-color: green;
    }
    #bottom {
      height: 50px;
      background-color: green;
    }
    #middle {
      flex: 1 0 100px;
      display: flex;
    }
    #left {
      width: 200px;
      overflow: auto;
      height: calc(100vh - 150px);
    }
    #right {
      flex: 1 0 600px;
      overflow: auto;
      height: calc(100vh - 150px);
      background-color: red;
    }

    .para {
      height: 300px;
      width: 500px;
      background-color: purple;
    }

    .para1 {
      height: 400px;
      background-color: pink;
    }
  </style>
  <body>
    <div id="parent">
      <div id="top">top</div>
      <div id="middle">
        <div id="left">
          left
          <div class="para">ccccc</div>
          <div class="para1">bbbbb</div>
        </div>
        <div id="right">
          <div class="para">aaaaa</div>
          <div class="para1">bbbbb</div>
        </div>
      </div>
      <div id="bottom">bottom</div>
    </div>
  </body>
</html>