【发布时间】:2016-02-12 05:48:23
【问题描述】:
我正在使用 Angular 2 构建一个项目,我需要一个粘性页脚,它必须始终位于页面底部,而不是固定的。示例:http://codepen.io/chriscoyier/pen/uwJjr
'app'组件的结构是这样的:
<header-main></header-main>
<router-outlet></router-outlet>
<footer>...</footer>
可能问题与 Angular 本身无关,而仅与 CSS 有关。但是,我尝试这样实现它:
app {
min-height: 100%;
position: relative;
}
footer {
position: absolute;
bottom: 0;
left: 0;
width: 100%;
height: 271px;
}
有趣的是,如果我在检查器中关闭页脚位置,然后再次打开,页脚就可以了:
解决方案:
app {
min-height: 100%;
width: 100%;
margin-bottom: -271px;
display: table;
}
header-main,
router-outlet,
footer{
display: table-row;
}
header-main {
height: 60px;
}
router-outlet {
position: absolute;
}
footer {
height: 271px;
}
【问题讨论】:
-
对此有什么解决办法吗?我面临同样的问题
-
任何回应。我需要你的帮助
-
非常感谢您发布解决方案
-
min-height: 100%;对我有用,我使用的是height: 100%