david2tdw / blog

学习记录
1 stars 1 forks source link

[CSS] 页面布局-SPA layout #215

Open david2tdw opened 2 years ago

david2tdw commented 2 years ago
  1. 当页面内容不足一屏的时候,bottom撑满一屏。
  2. 当页面内容超过一屏的时候,bottom自动扩展。
david2tdw commented 2 years ago
<!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>page layout</title>
    <style>
      html,
      body {
        height: 100%;
        margin: 0;
        padding: 0;
      }
      div {
        margin: 0;
        padding: 0;
      }
      #root {
        display: flex;
        flex-direction: column;
        height: 100%;
      }
      .outer-wrapper {
        flex: 1;
        background-color: aqua;
        padding: 0 20px;
      }
      .wrap {
        display: flex;
        flex-direction: column;
        background-color: yellow;
        height: 100%;
      }
      .top {
        background-color: tomato;
      }
      .bottom {
        background-color: rebeccapurple;
        flex: 1;
      }
      .inner {
        background-color: green;
      }
    </style>
  </head>
  <body>
    <div id="root">
      <div class="outer-wrapper">
        <div class="wrap">
          <div class="top">
            this is top part<br />
            this is top part<br />
            this is top part<br />
            this is top part<br />
          </div>
          <div class="bottom">
            this is bottom part.
            <div class="inner">this is bottom inner</div>
          </div>
        </div>
      </div>
    </div>
  </body>
</html>
david2tdw commented 2 years ago
<!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>page layout</title>
    <style>
      html,
      body {
        height: 100%;
        margin: 0;
        padding: 0;
      }
      div {
        margin: 0;
        padding: 0;
      }
      #root {
        display: flex;
        flex-direction: column;
        height: 100%;
      }
      .outer-wrapper {
        flex: 1;
        background-color: aqua;
        padding: 0 20px;
      }
      .wrap {
        display: flex;
        flex-direction: column;
        background-color: yellow;
        height: 100%;
      }
      .top {
        background-color: tomato;
      }
      .bottom {
        background-color: rebeccapurple;
        flex: 1;
      }
      .inner {
        background-color: green;
        height: 700px;
      }
    </style>
  </head>
  <body>
    <div id="root">
      <div class="outer-wrapper">
        <div class="wrap">
          <div class="top">
            this is top part<br />
            this is top part<br />
            this is top part<br />
            this is top part<br />
          </div>
          <div class="bottom">
            this is bottom part.
            <div class="inner">this is bottom inner</div>
          </div>
        </div>
      </div>
    </div>
  </body>
</html>