2017-10-05 64 views
0

我無法弄清楚如何讓頁腳粘到底部。如果內容小於尺寸頁腳應該在底部&如果內容大於窗口大小,頁腳應該在內容的結尾。我知道互聯網上有大量的材料,如何將腳註粘到底部。下面的代碼工作正常時,內容大:頁腳應該在頁面底部/內容

這裏是我的HTML:

<html> 
<body ng-cloak> 
    <notifications-bar class="notifications"></notifications-bar> 
    <div ng-controller="MainCtrl as main"> 
    <ng-include src="'app/layout/header.html'"></ng-include> 
    <div ng-view></div> 
    <ng-include src="'app/layout/footer.html'"></ng-include> 
    </div> 
    <spinner></spinner> 
</body> 
</html> 

這裏是CSS:

* { 
    margin: 0; 
} 

html { position: relative; min-height:100%; 
} 

html, body { margin:0px; padding:0px; 
} 

.footer_body { 
    background-color: rgb(102, 102, 102); 
    margin:0px; 
    position: relative; 
    top: 0px; 
    bottom: 0px; 
    width: 100%; 
} 
+0

爲了讓您的頁腳固定在底部,位置:固定;底部:0; –

回答

1

您的頁腳位置應該absoluterelativetop -styling應除去。也許檢查出bootstraps sticky footer source code。不管你是否使用bootstrap,粘性頁腳的樣式都是一樣的。

下面是它的基本部分:

html, body { 
 
    margin: 0; 
 
    padding: 0; 
 
} 
 
html { 
 
    position: relative; 
 
    min-height: 100%; 
 
} 
 
body { 
 
    margin-bottom: 60px; /* height of footer */ 
 
} 
 
.footer_body { 
 
    position: absolute; 
 
    bottom: 0; 
 
    width: 100%; 
 
    height: 60px; /* height of footer */ 
 
    background-color: rgb(102, 102, 102); 
 
}
<html> 
 
<body ng-cloak> 
 
    <notifications-bar class="notifications"></notifications-bar> 
 
    
 
    <div ng-controller="MainCtrl as main"> 
 
     <ng-include src="'app/layout/header.html'"></ng-include> 
 
     <div ng-view></div> 
 
    </div> 
 
    
 
    <footer class="footer_body"> 
 
     <ng-include src="'app/layout/footer.html'"></ng-include> 
 
    </footer> 
 
    <spinner></spinner> 
 
</body> 
 
</html>

+0

謝謝。請再幫我一次。 –

+0

如果您發現此問題可以解答您的問題,請考慮將其標記爲已回答。如果您有不同的問題,請隨時用它創建一個新問題,我會看看我能否提供幫助。 :-) –