有没有什么方法可以制作页眉,粘脚,页面和身体应该始终适合屏幕高度的100% - 页眉和页脚,只有HTML和CSS。查看更多图片。 100%身高的全屏页面
1
A
回答
1
您可以使用一种方法,使您可以保持身高达到100%,并且使用现代st恶心页脚的方法:
http://mystrd.at/modern-clean-css-sticky-footer/
步骤来实现这一目标:
箱尺寸:边界盒;
2. html {position:relative;高度:100%;}
3. body {text-align:center;最小高度:100%;保证金:0;溢出:隐藏;}
4.容器:绝对定位在标题高度的顶部。
5.页脚:绝对定位左边和底部:0;
看看这个演示:
html {
box-sizing: border-box;
}
*, *:before, *:after {
box-sizing: inherit;
}
html {
position: relative;
height: 100%;
}
body {
text-align:center;
min-height: 100%;
margin:0;
overflow:hidden;
}
footer {
position: absolute;
left: 0;
bottom: 0;
height: 50px; /* Height of Footer */
width: 100%;
}
header {
height: 50px; /* Height of header */
line-height:50px; /* vertical align the title*/
width: 100%;
background-color:lightgreen;
}
.container{
background-color: darkgreen;
height: 100%;
position: absolute;
top: 50px; /* Height of header */
left: 0;
bottom: 0;
width: 100%;
right: 0;
}
footer{
background-color:yellow;
line-height:50px; /* vertical align the title*/
}
<header>HEADER</header>
<div class="container"></div>
<footer>FOOTER</footer>
检查,你会看到,该机构将永远是100%的高度和页脚会在底部粘。
Ps。只是因为这是一个很好的做法,添加了框尺寸:边框,但这种方法没有必要。
-1
添加到您的CSS
html, body {
height: 100%;
}
并作出一个div,有你叫体内的含量,然后给它100%的高度。
举一个例子
<header>..</header>
<section id="content"> <--- HAS 100% IN HEIGHT.
....content
</section>
<footer>..</footer>
像这样:
#content {
width: 960px; <-- definable.
height: 100%;
}
0
如果您使用的容器在体内的头之后,那么你应该设置你的CSS这样的:
.container {width: 100%; height: 100%; content: "" ;}
相关问题
- 1. 全屏登陆页面高度100%不工作
- 2. 身高比屏幕高度大100%
- 3. CSS - 身高:100%vs最小身高:100%;
- 4. 身高未填充100%页高
- 5. html,身高100%
- 6. 身高是100%?
- 7. 100%身高列
- 8. CSS3身高100%
- 9. CSS高度页面高度的100%?
- 10. HTML/CSS:Div 100%页面高度
- 11. 身高:100% - 不是100%?
- 12. 100%的页面高度的应用程序主屏幕CSS
- 13. Css 100%身高:重新调整页面时,页脚滚动到内容页面
- 14. 100%身高的背景图片:需要填写页面
- 15. 如何使页面(非屏幕)高度的div为100%?
- 16. 根据全高100%的地毯页脚
- 17. 100%身高相对定位页脚
- 18. DIV - 力量高度100%= /页面高度?
- 19. HTML页面高度没有占用屏幕的全部高度
- 20. Twitter Bootstrap - 100%身高
- 21. 100%身高问题
- 22. 最小身高:100%?
- 23. 身高100%错误
- 24. CSS位置/高度 - 页100%对屏幕
- 25. 身高:100%VS身高:汽车
- 26. 视口100%身高不是身高100%,为什么?
- 27. SlickGrid父母的100%身高?
- 28. 使身体100%的高度
- 29. Div 100%页面响应的高度
- 30. 只有100%的高度填充页面
如果正文中包含大量内容,您想要滚动页面的哪一部分?只是身体部分? – Danield
身体不会有很多内容,可能只有一个输入和一些文本。 – Enve
请显示此问题的CSS和HTML。只需在你的问题中添加一个片段 –