页面布局(3)——多列定宽自适应

多列定宽自适应

<!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>定宽+自适应</title>
  <style>
    .left1 {

      float: left;
      width: 100px;
      margin-right: 20px;
    }

    .right2 {
      overflow: hidden;
    }

    .left2 {

      float: left;
      width: 100px;
    }

    .right2 {
      margin-left: 120px;
    }

    .parent3 {
      display: table;
      width: 100%;
      table-layout: fixed;
    }

    .left3 {
      width: 100px;
      padding-right: 20px;
    }

    .right3,
    .left3 {
      display: table-cell;
    }

    .parent4 {
      display: flex;
    }

    .left4 {
      width: 100px;
      margin-right: 20px;
    }

    .right4 {
      flex: 1;
    }

    .parent5 {
      width: 100%;
      display: -webkit-box;
    }

    .left5 {
      width: 100px;
      margin-right: 20px;
    }

    .right5 {
      -webkit-box-flex: 1;
    }
  </style>
</head>

<body>
  <!-- 使用float+overflow -->
  <div class="parent">
    <div class="left1">
      <p>
        left1
      </p>
    </div>
    <div class="right1">
      <p>
        right1
      </p>
      <p>
        right1
      </p>
    </div>
  </div>

  <!-- 使用float+margin -->
  <div class="parent">

    <div class="left2">

      <p>
        left2
      </p>

    </div>

    <div class="right2">

      <p>
        right2
      </p>

      <p>
        right2
      </p>

    </div>
  </div>
  <!-- 使用table -->
  <div class="parent3">

    <div class="left3">

      <p>
        left3
      </p>

    </div>

    <div class="right3">

      <p>
        right3
      </p>

      <p>
        right3
      </p>

    </div>
  </div>
  <!-- 使用flex -->
  <div class="parent4">

    <div class="left4">

      <p>
        left4
      </p>

    </div>

    <div class="right4">

      <p>
        right4
      </p>

      <p>
        right4
      </p>

    </div>
  </div>
  <!-- 使用display -->
  <div class="parent5">

    <div class="left5">
      left5
    </div>

    <div class="right5">
      right5
    </div>
</body>

</html>
posted @ 2018-09-07 16:03  Janas  阅读(171)  评论(0编辑  收藏  举报