zoukankan      html  css  js  c++  java
  • 有一个高度自适应的div,里面有两个div,一个高度100px,希望另一个填满剩下的高度。

    box-sizing方案     和 absolute position方案

           1.外层box-sizing: border-box; 同时设置padding: 100px 0 0

           2.内层100像素高的元素向上移动100像素,或使用absolute定位防止占据空间;

           3.另一个元素直接height: 100%;       代码如下   

           <!DOCTYPE html>
           <html lang="en">
           <head>
          <meta charset="UTF-8">
          <title>Title</title>
          <style type="text/css">

    html,
    body { height: 100%; padding: 0; margin: 0; }
    .outer { height: 100%; padding: 100px 0 0; box-sizing: border-box ; }
    .A { height: 100px; margin: -100px 0 0; background: #BBE8F2; }
    .B { height: 100%; background: #D9C666; }

    </style>


    </head>
    <body>
    <div class="outer">
    <div class="A"></div>
    <div class="B"></div>
    </div>

    </body>
    </html>

        第二种css  代码  如下 :

    html, body { height: 100%; padding: 0; margin: 0; }

    .outer { height: 100%; padding: 100px 0 0; box-sizing: border-box ; position: relative; }

    .A { height: 100px; background: #BBE8F2; position: absolute; top: 0 ; left: 0 ; 100%; }

    .B { height: 100%; background: #D9C666; }

      第三种css  代码 如下:

    html, body { height: 100%; padding: 0; margin: 0; }

    .outer { height: 100%; position: relative; }

    .A { height: 100px; background: #BBE8F2; }

    .B { background: #D9C666; 100%; position: absolute; top: 100px ; left: 0 ; bottom: 0; }

  • 相关阅读:
    js每天进步一点点
    优化数据库的方法及SQL语句优化的原则
    实用js代码大全
    【怒转】 idea快捷键说明大全(中英文对照)
    正则表达式手册
    Flink分布式缓存Distributed Cache
    初识Flink广播变量broadcast
    怒转一波,此人整理的Flink特别好
    flink批处理中的source以及sink介绍
    初识Flink-从WorldCount开始
  • 原文地址:https://www.cnblogs.com/loushiqiang/p/6739285.html
Copyright © 2011-2022 走看看