【发布时间】:2019-01-08 21:14:14
【问题描述】:
我正处于向 Angular 应用程序添加路由器转换的阶段,我面临着奇怪的问题。 router-outlet 的样式被应用到 DOM 层次结构中它下面的元素。
这是我的代码:
<main role="main">
<!-- Header -->
<app-header class="topnavbar-wrapper"></app-header>
<!-- Page content-->
<div [@fadeAnimation]="o.isActivated ? o.activatedRoute : ''">
<router-outlet #o="outlet"></router-outlet>
</div>
<!-- Footer -->
<app-footer></app-footer>
</main>
样式:
main {
box-sizing: border-box;
margin-top: 4.5rem;
min-height: 92vh;
padding-bottom: 4rem;
/* Height of footer */
position: relative;
}
router-outlet ~ * {
position: absolute;
height: 100%;
width: 100%;
}
footer {
position: absolute;
bottom: 0;
width: 100%;
color: #fff;
background-color: $secondary;
}
动画运行流畅,我对此没有任何问题。但是路由器插座样式应用于它下面的元素,这使得页脚固定在底部,覆盖了内容。如果我清除路由器插座元素的样式,那么动画将无法正常工作。
正如您在屏幕上看到的 <app-overview> 元素具有 router-outlet 样式,这就是导致问题的原因。我想解决方案在于正确的 scss 样式,但到目前为止我无法弄清楚。
【问题讨论】:
标签: html angular sass angular-animations