为了账号安全,请及时绑定邮箱和手机立即绑定

请教下当 top 高度不固定时又该怎么写?

请教下当 top 高度不固定时又该怎么写?

慕姐8265434 2023-04-16 14:10:16
上下两栏的css布局,外围的高度根据窗口大小而变动当 top 高度固定的时候怎么写bottom = wrap - top
查看完整描述

1 回答

?
慕的地6264312

TA贡献1817条经验 获得超6个赞

若要子容器填充父容器的话的设置。 bottom {height:100%; }
然后将top定位到warp顶部。 top {position: absolute; top: 0; height: 100px;}
此时top会覆盖到bottom上方,所以需要将bottom向下移动。 .warp {padding: 100px}
就ok了,但是会有一个问题就是warp的实际高度是width + padding-top。

.wrap {    height: 90%;    background: green;    color: #FFF;    position: relative;    padding-top: 100px;
}#top {    background: blue;    height: 100px;    width: 100%;    position: absolute;    top: 0;
}#bottom {    background: red;    height: 100%;
}

你说的top高度不固定是指bottom高度是固定的吗?那样的话只需要调换一下位置就好了 一样的写法。

<p>...</p>


查看完整回答
反对 回复 2023-04-18
  • 1 回答
  • 0 关注
  • 88 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信