有沒有什麼方法可以製作頁眉,粘腳,頁面和身體應該始終適合屏幕高度的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。只需在你的問題中添加一個片段 –