css使填充满剩余空间.md

简书迁移

Posted by thrfox on June 29, 2020
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<div id="main">
    <div id="nav">nav</div>
    <div id="content">content</div>
</div>

#nav {
    background-color: #85d989;
    width: 100%;
    height: 50px;
}
#content {
    background-color: #cc85d9;
    width: 100%;
    position: absolute;
    top: 50px;
    bottom: 0px;
    left: 0px;
}

重点是要top和bottom一起使用,这是很反常规的用法,可以强制定义盒模型的区域,神奇啊