欢迎光临
感谢一路有你

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

如果你对该文章中的内容有疑问/不解,可以点击此处链接提问
要注明问题和此文章链接地址 点击此处跳转
 

方案1:

Html:

1
2
3
4
<div class="outer">
    <div class="A"> 头部DIV </div>
    <div class="B">下部DIV </div>
</div>

CSS:

1
2
3
4
5
html,
body { height: 100%; padding: 0; margin: 0; }
.outer { height: 100%; padding: 100px 0 0; box-sizing: border-box ; position: relative; }//三padding: 100px 0 100px 0;
.A { height: 100px; background: #BBE8F2; position: absolute; top: 0 ; left: 0 ; width: 100%; }
.B { height: 100%; background: #D9C666; }

 

方案2:

HTML:

1
2
3
4
<div class="outer">
    <div class="A">头部DIV</div>
    <div class="B">下部DIV</div>
</div>

CSS:

1
2
3
4
5
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; }

效果:

赞(2) 打赏
未经允许不得转载:王明昌博客 » div 自适应高度 自动填充剩余高度
分享到: 更多 (0)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏