div 自适应高度 自动填充剩余高度

方案1:

Html:

<div class="outer">
    <div class="A"> 头部DIV </div>
    <div class="B">下部DIV </div>
</div>

CSS:

html,
body { height100%padding0margin0; }
.outer { height100%padding100px 0 0; box-sizing: border-box ; positionrelative; }
.A { height100pxbackground#BBE8F2positionabsolutetop0 left0 width100%; }
.B { height100%background#D9C666; }

效果:

 

方案2:

HTML:

<div class="outer">
    <div class="A">头部DIV</div>
    <div class="B">下部DIV</div>
</div>

CSS:

html,
body { height100%padding0margin0; }
.outer { height100%padding100px 0 0; box-sizing: border-box ; }
.A { height100pxmargin-100px 0 0background#BBE8F2; }
.B { height100%background#D9C666; }

效果:

 

文章转自:https://www.cnblogs.com/pangguoming/p/5695184.html

posted @ 2019-02-13 16:50  neo_o  阅读(2220)  评论(0编辑  收藏  举报

愿你的生活只有诗和远方