我使用的引導程序未經任何修改。佈局非常簡單。我有一個頂級的導航欄。然後是主容器。最後,我有一個頁腳。類似於:無法獲取頁腳佔用屏幕的其餘部分
<head>
<style>
body {
padding-top: 60px; /* 60px to make the container go all the way to the bottom of the topbar */
background-color: #ECECEC;
}
</style>
</head>
<body>
<div class="navbar navbar-inverse navbar-fixed-top">
// navbar elements
</div> <!-- end of class navbar -->
<div class="container">
// fluid-row class with two column structure
</div> <!-- end of class container -->
<div class="footer">
<div class="container"> <!-- using container to left-align footer to the main content -->
// some content
</div> <!-- end of class footer -->
</body>
有兩件事情是無法做到的。
1)每當主容器類中的內容較少時,我需要將頁腳對齊到屏幕底部。我試過最小高度:100%,但我做錯了什麼。
2)我需要頁腳有不同的背景顏色,一旦主容器結束,頁腳應該佔據屏幕的其餘部分。頁腳可以具有最小高度,或根據頁腳內的內容獲取高度。
.footer {
height:80px;
margin-top:-80px;
position:relative;
clear:both;
padding-top:20px;
background-color:#F4F4F4;
border-top:1px solid #ddd;
clear:both;
}
這是怎麼回事?
的jsfiddle:http://jsfiddle.net/m7dkt/13/
謝謝!但是這會產生粘性的頁腳。如果主容器的內容較少,我希望頁尾顯示結束。否則,頁腳應顯示在容器下方的正常位置。那可能嗎? –