css布局中间固定两边自适应

<!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>css布局中间固定两边自适应</title>
  <style>
    /* 1、利用弹性布局 */
    .box{
      display: flex;
    }
    .left_self {
      min-height: 100px;
      background: #987;
      flex: 1;
    }

    .right_self {
      min-height: 100px;
      background: #369;
      flex: 1;
    }

    .center_self {
      width: 500px;
      min-height: 100px;
      background: #192;
    }
  </style>
</head>

<body>
  <h2>1、利用弹性布局</h2>
  <div class="box">
    <div class="left_self">我是左边</div>
    <div class="center_self">我是中间</div>
    <div class="right_self">我是右边</div>
  </div>
</body>
</html>

猜你喜欢

转载自blog.csdn.net/sleepwalker_1992/article/details/82802231