html - Angular 2 粘性页脚实现

标签 html css angular sticky-footer

我希望我的页脚成为粘性页脚并尝试遵循 css tricks negative margin trick,但没有奏效。我试图在下面的 plunker 代码中模拟我的 angular2 应用程序。我希望贴纸不是固定的而是粘性的,并在主要部分中有更多内容时转到底部。请注意,页脚显示在主要部分的数据上方。

http://plnkr.co/edit/WSUC4xLMWH6fY77UyFqI?p=preview&open=app%2Fapp.component.ts

应用程序组件:

<nav-bar></nav-bar>
  <section class="main">
    <div class="main-container">
      Display my router-outlet here          
      <ul>
      <li *ngFor="let hero of heroes">
        {{ hero }}
      </li>
    </ul>

    </div>
  </section>
  <footer-component></footer-component>

感谢任何修复和向下移动页脚的帮助。

最佳答案

你仍然可以按照提到的这个例子 https://philipwalton.github.io/solved-by-flexbox/demos/sticky-footer/

只需将此代码添加到 styles.scss

html, 
body {
  height: 100%;
}

在你的app.component.scss

:host {
  display: flex;
  min-height: 100%; // used percent instead of vh due to safari bug.
  flex-direction: column;
}

.Site-content {
  flex: 1;
}

在你的app.component.html

<header>...</header>

<main class="Site-content">..</main>

<footer>...</footer>

关于html - Angular 2 粘性页脚实现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42520346/

相关文章:

php - 如何在 SQL 语句中使用 PHP 变量

javascript - IE6/7 Google Maps tile transparency - 我看不到 map

html - 隐藏类 Bootstrap 不起作用?

javascript - 运行命令 ""时无效的 JSON 字符 : "ng update @angular/cli --migrate-only --from=1.7.4" at 0:0.

javascript - Angular 5 document.querySelector ('ClassName' ).innerHTML 不包含内联的 css

php - 如何使表格将相同的列打印到一行中?

javascript - 用灰色覆盖整个 html 页面以指示临时禁用

html - 导航文本干扰常规?

angular - 在 firebase 云函数中部署 nestjs

html - 当父 div 的水平滚动可见时,如何在顶部父 div 上显示子 div