zoukankan      html  css  js  c++  java
  • 一个定高,一个高度自适应的布局

    Problem:父元素内包含两个子元素,一个定高,另一个高度自适应

    Ans:

    <div class="box">
        <div class="ele1"></div>
        <div class="ele2"></div>
    </div>

    (1)
      .box {
          200px;
          height:300px;
          background:red;
          display:flex;
          flex-direction:column;
      }
       .ele1 {
          height:100px;
          background:green;
      }
        .ele2 {
           background:blue;
           flex:1;
       }
     (2)

    .box { 
        100px; 
        height:300px; 
        background:red; 
        position:relative; 
     } 
     .ele1 { 
        height: 100px; 
        background:green; 
     } 
     .ele2 { 
        background:blue; 
        100px; 
        position:absolute; 
        top:100px; 
        bottom:0; 
     }

    (3)

    html, body { 
        height: 100%; 
        padding: 0; 
        margin: 0; 
    } 
    .box { 
          height: 100%;} 
    .ele1 { 
        height: 100px; 
        background:purple; 
    } 
    .ele2 { 
        height: calc(100% - 100px); 
        background:blue; 
    }

    (4)

    html, body { 
        height: 100%; 
        padding: 0; 
        margin: 0; 
    } 
    .box { 
        height: 100%; 
        padding: 100px 0 0; 
        box-sizing: border-box ; 
        position: relative; 
    } 
    .ele1 { 
        height: 100px; 
        background: #BBE8F2; 
        position: absolute; 
        top: 0 ; 
        left: 0 ; 
         100%; 
    } 
    .ele2 { 
        height: 100%; 
        background: #D9C666; 
    }

    (5)

    html, body { 
        height: 100%; 
        padding: 0; 
        margin: 0; } 
    .box { 
        height: 100%; 
        position: relative; 
    } 
    .ele1 { 
        height: 100px; 
        background:purple; 
    } 
    .ele2 { 
        background:blue; 
         100%; 
        position: absolute; 
        top: 100px ; 
        left: 0 ; 
        bottom: 0; 
    }

    参考:https://segmentfault.com/q/1010000000762512

     

     

     

    宝剑锋从磨砺出,梅花香自苦寒来。
  • 相关阅读:
    Python strip()方法介绍
    python实现猜拳游戏
    Shopping cart program--python
    转置矩阵的行和列
    Oldman python of full stack-Day2
    根据输入生成二维码
    python 中设置字体/背景颜色
    如何用Notepad++运行python程序
    web前端【第十篇】jQuery基本语法
    web前端【第九篇】JS的DOM对象三
  • 原文地址:https://www.cnblogs.com/haimengqingyuan/p/6858838.html
Copyright © 2011-2022 走看看