zoukankan      html  css  js  c++  java
  • html 布局,上下各100px,中间自适应

    flex

    <!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>
          body {
            margin: 0px;
            padding: 0px;
            height: 100vh;
            display: flex;
            flex-direction: column;
          }
          .top,
          .bottom {
            height: 100px;
            background-color: red;
          }
          .center {
            background-color: pink;
            flex: 1;
          }
        </style>
      </head>
      <body>
        <div class="top"></div>
        <div class="center"></div>
        <div class="bottom"></div>
      </body>
    </html>
    

    绝对定位

    <!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 {
            margin: 0px;
            padding: 0px;
            height: 100vh;
            position: relative;
            overflow: hidden;
          }
          .top,
          .bottom {
            height: 100px;
            background-color: red;
          }
          .top {
            position: absolute;
            left: 0;
            top: 0;
             100%;
          }
          .bottom {
            position: absolute;
            left: 0;
            bottom: 0;
             100%;
          }
          .center {
            box-sizing: border-box;
             100%;
            height: 100%;
            padding: 100px 0;
          }
    
          .content {
            height: 100%;
            background-color: blue;
             100%;
          }
        </style>
      </head>
      <body>
        <div class="top"></div>
        <div class="center">
          <div class="content"></div>
        </div>
        <div class="bottom"></div>
      </body>
    </html>
    

    grid

    <!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 {
            margin: 0px;
            padding: 0px;
            height: 100vh;
            overflow: hidden;
            display: grid;
            grid-template-rows: 100px auto 100px;
          }
          .top,
          .bottom {
            background-color: rgba(255, 0, 0, 0.5);
          }
          .center {
            background-color: blue;
          }
        </style>
      </head>
      <body>
        <div class="top"></div>
        <div class="center"></div>
        <div class="bottom"></div>
      </body>
    </html>
    
  • 相关阅读:
    服务器端口
    Format(const wchar_t *,...)”: 不能将参数 1 从“const char [3]”转换为“const wchar_t *”.
    图片格式
    CreateEx
    电力谐波
    [OGeek2019]babyrop
    Simple Inject
    [GXYCTF2019]BabySQli
    [CISCN2019 华北赛区 Day2 Web1]Hack World
    极客大挑战2019
  • 原文地址:https://www.cnblogs.com/ajanuw/p/12487726.html
Copyright © 2011-2022 走看看