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>
    
  • 相关阅读:
    【漏洞挖掘】攻击对外开放的Docker API接口
    使用密钥认证机制远程登录Linux
    极客时间-左耳听风-程序员攻略开篇-零基础启蒙
    WEBSHELL恶意代码批量提取清除工具
    string替换字符串,路径的斜杠替换为下划线
    Linux下文件的三个时间意义及用法
    记录一次lnmp故障报告
    Centos 7.2编译安装MariaDB-10.0.xx
    win 7 浏览器被篡改小插曲
    【 sysbench 性能基准测试 】
  • 原文地址:https://www.cnblogs.com/ajanuw/p/12487726.html
Copyright © 2011-2022 走看看