
需求:
1. 這個矩形的高度和瀏覽器窗口的高度相同,不能出現縱向滾動條
2. 綠色部分高度固定,比如50px
3. 紫色部分填充剩余的高度
HTML結構:
<div id="main"> <div id="nav">nav</div> <div id="content">content</div> </div>
需求1實現:
html, body { height: 100%; margin: 0px; padding: 0px; } #main { background-color: #999; height: 100%; }
需求2實現:
#nav { background-color: #85d989; height: 50px; }
需求3實現(絕對布局+top(nav的height值)+bottom(0)):
#content { background-color: #cc85d9; width: 100%; position: absolute; top: 50px; bottom: 0px; left: 0px; }
