【发布时间】:2019-04-05 07:25:03
【问题描述】:
我有一个带有简单模板的 angularJS web 应用程序:
<html>
<head>
<link rel="stylesheet" href="style.css" />
</head>
<body id="top">
<!-- Templates with views will be inserted here -->
<div class="wrapper" ng-view>
<div class="language-loaded">
<div class="home-top">
<div class="title-wrapper">
<h1 class="home-title">Title</h1>
</div>
</div>
<div>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
<p>content</p>
</div>
</div>
</div>
<!-- This is the footer template -->
<div ng-include src="'partials/footer.html'">
<footer id="footer">
This is the footer
</footer>
</div>
生成的网页是这样的:
HTML:
<body id="top">
<div class="wrapper">
</body>
</html>
CSS:
html, body, .wrapper, .language-loaded, .home-top {height: 100%}
body { background-color: #F5F5F5}
.home-top {background-color: blue;}
.title-wrapper {
position: relative;
top: 39%;
color: #fff;
text-align: center;
}
如您所见,我在某些组件中有一个 height:100% ,因为我希望主页打开一个具有 100% 高度的背景图像。在这张图片下面有一些主要内容。关键是,在这种结构下,页脚显示在背景图像的正下方,在主要内容之上。
请看这个plunker更清楚地看到问题:https://plnkr.co/edit/gyNOJmc5uzHAEhXwzRuq?p=preview
我希望将页脚放在页面末尾,正如预期的那样,位于整个主要内容的下方。
【问题讨论】:
-
好吧,如果 .wrapper 的高度为:100%,那么 #footer 就没有空间了,除非你想将两者重叠
-
好的。但是我应该怎么做才能让一切正常工作呢?
-
<footer>周围的<div>的用途是什么? -
请注意,它是一个 AngularJS 模板:因此 div 来自: 里面是页脚。但是,我认为这并没有解决问题。