好的,所以我知道这个主题有很多问题,但我仍然无法确切地知道如何使这项工作.
This接近问题,但它不适合我.
我希望我的页面有100%的高度.在此页面内是一个高度为40px的静态标题,然后是剩余高度(100% – 40px)的内容.
HTML:
- <body>
- <div id="page">
- <div id="header">
- header
- </div>
- <div id="content">
- content
- </div>
- </div>
- </body>
CSS:
- html,body
- {
- height: 100%;
- margin: 0px;
- }
- #page
- {
- min-height: 100%;
- }
- #header
- {
- height: 40px;
- }
- #content
- {
- height: 100%;
- position: absolute;
- top: 0;
- padding-top: 40px;
- }
这是代码的解释:
>我添加了位置:绝对内容,因为否则由于某种原因它不会占用其容器#page的100%
>然后问题是它超出了页面的边界,这就是我添加top:0的原因.
>然后#content的内容与标题重叠,所以我添加了padding-top:40px
>现在#content再次超出了页面的边界
有什么建议?谢谢.
解决方法
这应该工作:
- #content
- {
- height: auto;
- width: 100%;
- position: absolute;
- top: 40px;
- bottom: 0;
- }