2017-10-05 61 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

如果您发现此问题可以解答您的问题,请考虑将其标记为已回答。如果您有不同的问题,请随时用它创建一个新问题,我会看看我能否提供帮助。 :-) –