zoukankan      html  css  js  c++  java
  • 三栏布局——纵向

    上下固定宽度100px;中间部分自适应

    方案一:绝对定位方式

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Document</title>
        <style>
            *{
                padding: 0;
                margin: 0;
            }
            html,body{
                height:100%;
                overflow: hidden;
            }
            .wrap{
                position: relative;
                height: 100%;
                width: 100%;
            }
            .wrap div{
                position: absolute;
                width: 100%;
                left: 0;
            }
            .head{
                top: 0;
                height: 100px;
                background: #666;
            }
            .foot{
                bottom: 0;
                height: 100px;
                background: #666;
            }
            .center{
                top: 100px;
                bottom: 100px;
                background: #EEE;
            }
        </style>
    </head>
    <body>
        <div class="wrap">
            <div class="head"></div>
            <div class="center">
            </div>
            <div class="foot"></div>
        </div>
    </body>
    </html>

    注意html和body需要设置height:100% ,自适应部分需要进行上下同时定位

    方案二:flex布局

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Document</title>
        <style>
            *{
                padding: 0;
                margin: 0;
            }
            html,body{
                height:100%;
                overflow: hidden;
            }
            .wrap{
                display: flex;
                flex-direction: column;
                height: 100%;
                width: 100%;
            }
            .head{
                height: 100px;
                background: #666;
            }
            .foot{
                height: 100px;
                background: #666;
            }
            .center{
                flex: 1;
                background: #EEE;
            }
        </style>
    </head>
    <body>
        <div class="wrap">
            <div class="head"></div>
            <div class="center">
            </div>
            <div class="foot"></div>
        </div>
    </body>
    </html>

    注意html和body需要设置height:100% ,父元素设置display:flex 及规定排列方向 flex-direction:column,定高部分设置高度,不定高部分设置flex:1

     
  • 相关阅读:
    纹理贴图的模式设置
    vs debug或者release文件夹下的 .exe文件
    subpixel的概念
    点乘
    设置开机时自动开启和关闭的软件
    CF553E Kyoya and Train
    CF960G Bandit Blues
    玩游戏
    「SWTR03」Counting Trees
    CF623E Transforming Sequence
  • 原文地址:https://www.cnblogs.com/yiyi111/p/12365041.html
Copyright © 2011-2022 走看看