wolichuang / dailyInterview

面试、工作中遇到的issue
0 stars 0 forks source link

使用flex实现三栏布局,两边固定,中间自适应 #9

Open wolichuang opened 3 years ago

wolichuang commented 3 years ago
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      html,
      body {
        width: 100%;
        height: 100%;
      }
      body {
        margin: 0 auto;
      }
      .container {
        width: 100%;
        height: 100%;
        display: flex;
      }
      .left,
      .right {
        flex: 0 0 auto;
        width: 250px;
        height: 100%;
      }
      .content {
        flex: 1 1 auto;
        height: 100%;
      }
      .red {
        background-color: coral;
      }
      .blue {
        background-color: cornflowerblue;
      }
    </style>
  </head>
  <body>
    <div class="container">
      <div class="left red">left</div>
      <div class="content">middle</div>
      <div class="right blue">right</div>
    </div>
  </body>
</html>