【Css】使用弹性盒实现三栏布局

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
  <style>
    *{
      margin: 0;
      padding: 0;
    }
    body,html{
      height: 100%;
    }
    body{
      display: flex;
    }
    .box1,.box3{
      width: 100px;
      background: #164e7f;
    }
    .box2{
      flex: 1;
      background: #ffa4b2;
    }
  </style>
</head>
<body>
<div class="box1"></div>
<div class="box2"></div>
<div class="box3"></div>
</body>
</html>

 

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
  <style>
    *{
      margin: 0;
      padding: 0;
    }
    body,html{
      height: 100%;
    }
    body{
      display: flex;
      flex-direction: column;
    }
    .box1,.box3{
      height: 100px;
      background: #164e7f;
    }
    .box2{
      flex: 1;
      background: #ffa4b2;
    }
  </style>
</head>
<body>
<div class="box1"></div>
<div class="box2"></div>
<div class="box3"></div>
</body>
</html>

posted @ 2022-05-08 16:26  木子欢儿  阅读(91)  评论(0编辑  收藏  举报