我目前很難讓頁面的頁腳正常工作。我認爲這是因爲我的固定位置的標題和容器div,但我需要將它們固定,以便在滾動時保持最佳狀態。我不知道如何考慮這個問題,當容器div空了時,頁腳出現在底部。在固定div下的頁腳
HTML: -
<body>
<div id="wrapper">
<div id="header">
<div id="headerContent">
</div>
</div>
<script>
$(document).ready(function() {
$('#container').css('marginTop', $('#header').outerHeight(true) + $('#navbar').outerHeight(true));
});
</script>
<div id="navbar">
<div id ="navbarContent">
</div>
</div>
<div id="container">
</div>
<div id="footer">
<div id="footerContent">
</div>
</div>
</div>
</body>
</html>
CSS: -
#container{
width:960px;
margin:auto;
overflow:hidden;
}
#wrapper{
min-height:100%;
position:relative;
}
#navbar{
width:100%;
height:40px;
margin:auto;
background-color:#4e8885;
position:fixed;
top:120px;
padding:0px;
}
#header{
width:100%;
height:120px;
margin:auto;
background-color:#8bbcba;
position:fixed;
top:0px;
}
#footer{
width:100%;
min-height:20px;
margin:auto;
background-color:#8bbcba;
position:absolute;
bottom:0;
left:0;
}
你有沒有在線工作的示例頁面? –
你的意思是你想讓頁腳在屏幕底部像工具欄一樣保持固定,或者你的意思是你想讓它拉低到低於任何內容? –
@PeterFeatherstone不,我只希望頁腳與頁面底部一致,所以如果容器沒有內容,例如 – user1060187